From 7cbacc253c694bfe9f57ac8198dc59e672407aeb Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 30 Jan 2024 14:00:17 +0000 Subject: [PATCH] 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 --- t/db_dependent/Koha/Biblio.t | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) 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; -- 2.30.2