From c614342f2743b1076b6a7a6740ea6586acf547ac Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Sat, 21 Jan 2017 16:45:34 +0100 Subject: [PATCH] Bug 17974: Add the Koha::Item->biblio method Test plan: prove t/db_dependent/Koha/Items.t should return green Signed-off-by: Josef Moravec Signed-off-by: Nick Clemens --- Koha/Item.pm | 14 ++++++++++++++ t/db_dependent/Koha/Items.t | 10 +++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Koha/Item.pm b/Koha/Item.pm index 52a77001f9..da3d11a3c8 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -77,6 +77,20 @@ sub holding_branch { return $self->{_holding_branch}; } +=head3 biblio + +my $biblio = $item->biblio; + +Return the bibliographic record of this item + +=cut + +sub biblio { + my ( $self ) = @_; + my $biblio_rs = $self->_result->biblio; + return Koha::Biblio->_new_from_dbic( $self->_result->biblio ); +} + =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 843bf443eb..c9d4bac258 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 => 5; +use Test::More tests => 6; use C4::Circulation; use Koha::Item; @@ -74,6 +74,14 @@ subtest 'get_transfer' => sub { is( $transfer->itemnumber, $new_item_1->itemnumber, 'Koha::Item->get_transfer should return a valid Koha::Item::Transfers object' ); }; +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( $biblio->biblionumber, $retrieved_item_1->biblionumber, 'Koha::Item->biblio should return the correct biblio' ); +}; + $retrieved_item_1->delete; is( Koha::Items->search->count, $nb_of_items + 1, 'Delete should have deleted the item' ); -- 2.39.5