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 <josef.moravec@gmail.com> Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
parent
2f763a9689
commit
c614342f27
2 changed files with 23 additions and 1 deletions
14
Koha/Item.pm
14
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;
|
||||
|
|
|
@ -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' );
|
||||
|
||||
|
|
Loading…
Reference in a new issue