From 6527b3b67506db0289997eb9bb98647fa1967a55 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Wed, 19 Apr 2017 17:01:54 +0200 Subject: [PATCH] Bug 18459: Add the Koha::Item->biblioitem method MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Test plan: prove t/db_dependent/Koha/Items.t Signed-off-by: Marc Véron Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall --- Koha/Item.pm | 14 ++++++++++++++ t/db_dependent/Koha/Items.t | 12 ++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/Koha/Item.pm b/Koha/Item.pm index a921018d74..44dc2f5348 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -92,6 +92,20 @@ sub biblio { return Koha::Biblio->_new_from_dbic( $biblio_rs ); } +=head3 biblioitem + +my $biblioitem = $item->biblioitem; + +Return the biblioitem record of this item + +=cut + +sub biblioitem { + my ( $self ) = @_; + my $biblioitem_rs = $self->_result->biblioitem; + return Koha::Biblioitem->_new_from_dbic( $biblioitem_rs ); +} + =head3 get_transfer my $transfer = $item->get_transfer; diff --git a/t/db_dependent/Koha/Items.t b/t/db_dependent/Koha/Items.t index c9d4bac258..6452c4e57d 100644 --- a/t/db_dependent/Koha/Items.t +++ b/t/db_dependent/Koha/Items.t @@ -19,7 +19,7 @@ use Modern::Perl; -use Test::More tests => 6; +use Test::More tests => 7; use C4::Circulation; use Koha::Item; @@ -78,10 +78,18 @@ subtest 'biblio' => sub { plan tests => 2; my $biblio = $retrieved_item_1->biblio; - is( ref( $biblio ), 'Koha::Biblio', 'Koha::Item->bilio should return a Koha::Biblio' ); + is( ref( $biblio ), 'Koha::Biblio', 'Koha::Item->biblio should return a Koha::Biblio' ); is( $biblio->biblionumber, $retrieved_item_1->biblionumber, 'Koha::Item->biblio should return the correct biblio' ); }; +subtest 'biblioitem' => sub { + plan tests => 2; + + my $biblioitem = $retrieved_item_1->biblioitem; + is( ref( $biblioitem ), 'Koha::Biblioitem', 'Koha::Item->biblioitem should return a Koha::Biblioitem' ); + is( $biblioitem->biblionumber, $retrieved_item_1->biblionumber, 'Koha::Item->biblioitem should return the correct biblioitem' ); +}; + $retrieved_item_1->delete; is( Koha::Items->search->count, $nb_of_items + 1, 'Delete should have deleted the item' ); -- 2.39.5