From 7a59118d1eba3f7bba9ad99fa7ad8213a0f10042 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 16 Jan 2024 09:47:10 +0000 Subject: [PATCH] Bug 35787: Add unit test for filter_by_bookable Trivial test added for filter_by_bookable --- t/db_dependent/Koha/Items.t | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Items.t b/t/db_dependent/Koha/Items.t index 26f81dd7d4a..a7e1fc72c16 100755 --- a/t/db_dependent/Koha/Items.t +++ b/t/db_dependent/Koha/Items.t @@ -19,7 +19,7 @@ use Modern::Perl; -use Test::More tests => 16; +use Test::More tests => 17; use Test::MockModule; use Test::Exception; @@ -2000,3 +2000,26 @@ subtest 'filter_by_for_hold' => sub { $schema->storage->txn_rollback; }; + +subtest 'filter_by_bookable' => sub { + plan tests => 2; + + $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( $biblio->items->filter_by_bookable->count, 1, "filter_by_bookable returns the correct number of items" ); + is( + $biblio->items->filter_by_bookable->next->itemnumber, $bookable_item1->itemnumber, + "the correct item is returned from filter_by_bookable" + ); + + $schema->storage->txn_rollback; +}; -- 2.43.0