From a6ef5d7ec27a114247d5d1e239212303768342fd Mon Sep 17 00:00:00 2001 From: Lari Taskula Date: Mon, 10 Apr 2017 11:49:50 +0000 Subject: [PATCH] Bug 18408: Get remainder of title (245$b) from Koha::Biblio To test: 1. prove t/db_dependet/Koha/Biblios.t --- Koha/Biblio.pm | 15 +++++++++++++++ t/db_dependent/Koha/Biblios.t | 13 +++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index 338e5a6..2e7b6e2 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -370,6 +370,21 @@ sub biblioitem { return $self->{_biblioitem}; } +=head3 title_remainder + +my $field = $self->title_remainder + +Returns the Remainder of title, 245$b. + +=cut + +sub title_remainder { + my ($self) = @_; + + return unless my $record = C4::Biblio::GetMarcBiblio($self->biblionumber); + return $record->subfield('245','b'); +} + =head3 type =cut diff --git a/t/db_dependent/Koha/Biblios.t b/t/db_dependent/Koha/Biblios.t index eaf350d..b46d433 100644 --- a/t/db_dependent/Koha/Biblios.t +++ b/t/db_dependent/Koha/Biblios.t @@ -19,7 +19,7 @@ use Modern::Perl; -use Test::More tests => 2; +use Test::More tests => 3; use C4::Biblio; use C4::Items; @@ -116,6 +116,15 @@ subtest 'can_be_transferred' => sub { .' invalid library is given.'); }; +subtest 'title_remainder' => sub { + plan tests => 1; + + my ($bibnum, $title, $bibitemnum) = create_helper_biblio('BK'); + + my $biblio = Koha::Biblios->find($bibnum); + is($biblio->title_remainder, 'Remainder', 'Got remainder of title'); +}; + $schema->storage->txn_rollback; @@ -127,7 +136,7 @@ sub create_helper_biblio { $title = 'Silence in the library'; $bib->append_fields( MARC::Field->new('100', ' ', ' ', a => 'Moffat, Steven'), - MARC::Field->new('245', ' ', ' ', a => $title), + MARC::Field->new('245', ' ', ' ', a => $title, b => 'Remainder'), MARC::Field->new('942', ' ', ' ', c => $itemtype), ); return ($bibnum, $title, $bibitemnum) = AddBiblio($bib, ''); -- 2.7.4