diff --git a/t/db_dependent/Koha/Biblio.t b/t/db_dependent/Koha/Biblio.t index 13be09f466..5624ac28c1 100755 --- a/t/db_dependent/Koha/Biblio.t +++ b/t/db_dependent/Koha/Biblio.t @@ -17,7 +17,7 @@ use Modern::Perl; -use Test::More tests => 30; +use Test::More tests => 31; use Test::Exception; use Test::Warn; @@ -486,6 +486,40 @@ subtest 'to_api() tests' => sub { $schema->storage->txn_rollback; }; +subtest 'bookings() tests' => sub { + + plan tests => 3; + + $schema->storage->txn_begin; + + my $biblio = $builder->build_sample_biblio(); + + is( ref( $biblio->bookings ), 'Koha::Bookings', 'Return type is correct' ); + + is_deeply( + $biblio->bookings->unblessed, + [], + '->bookings returns an empty Koha::Bookings resultset' + ); + + my $booking = $builder->build_object( + { + class => 'Koha::Bookings', + value => { biblio_id => $biblio->biblionumber } + } + ); + + my $bookings = $biblio->bookings->unblessed; + + is_deeply( + $biblio->bookings->unblessed, + [ $booking->unblessed ], + '->bookings returns the related Koha::Booking objects' + ); + + $schema->storage->txn_rollback; +}; + subtest 'suggestions() tests' => sub { plan tests => 3;