Bug 35248: Add Koha::Biblio->bookings unit test

This patch adds unit tests for the bookings relationship accessor on
Koha::Biblio objects.

Test plan
1) Run t/db_dependant/Koha/Biblio.t

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Martin Renvoize 2024-01-30 14:00:17 +00:00 committed by Katrin Fischer
parent 5384aea510
commit 4d8020258f
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834

View file

@ -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;