From db97a5d65a5087b2419e6e9b01fd432257717cbc Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 7 Feb 2024 16:38:20 +0000 Subject: [PATCH] Bug 35248: Add unit tests for Koha::Bibilio->bookable_items This patch adds basic unit tests for Koha::Biblio->bookable_items Test plan 1) Run t/db_dependent/Koha/Biblio.t Signed-off-by: David Nind --- t/db_dependent/Koha/Biblio.t | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Biblio.t b/t/db_dependent/Koha/Biblio.t index b17e02c137..017aeecc9f 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 => 32; +use Test::More tests => 33; use Test::Exception; use Test::Warn; @@ -148,6 +148,30 @@ subtest 'items() tests' => sub { }; +subtest 'bookable_items() tests' => sub { + plan tests => 3; + + $schema->storage->txn_begin; + + my $biblio = $builder->build_sample_biblio(); + + # bookable items + my $bookable_item1 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber, bookable => 1 } ); + + # not bookable items + my $non_bookable_item1 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber, bookable => 0 } ); + my $non_bookable_item2 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber, bookable => 0 } ); + + is( ref( $biblio->bookable_items ), 'Koha::Items', "bookable_items returns a Koha::Items resultset" ); + is( $biblio->bookable_items->count, 1, "bookable_items returns the correct number of items" ); + is( + $biblio->bookable_items->next->itemnumber, $bookable_item1->itemnumber, + "bookable_items returned the correct item" + ); + + $schema->storage->txn_rollback; +}; + subtest 'get_coins and get_openurl' => sub { plan tests => 4; -- 2.30.2