From bbe8dc1e461165956650130f755d27db79222c83 Mon Sep 17 00:00:00 2001 From: Petro Vashchuk Date: Thu, 6 May 2021 15:43:15 +0300 Subject: [PATCH] Bug 28286: tests for "filter_by_for_hold" method --- t/db_dependent/Koha/Items.t | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Items.t b/t/db_dependent/Koha/Items.t index 73e1ab4a29..cffc15179a 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 => 14; +use Test::More tests => 15; use Test::MockModule; use Test::Exception; @@ -1483,6 +1483,21 @@ subtest 'filter_by_for_loan' => sub { $biblio->delete; }; +subtest 'filter_by_for_hold' => sub { + plan tests => 4; + + my $biblio = $builder->build_sample_biblio; + is( $biblio->items->filter_by_for_hold->count, 0, 'no item yet' ); + $builder->build_sample_item( { biblionumber => $biblio->biblionumber, notforloan => 1 } ); + is( $biblio->items->filter_by_for_hold->count, 0, 'no item for hold' ); + $builder->build_sample_item( { biblionumber => $biblio->biblionumber, notforloan => 0 } ); + is( $biblio->items->filter_by_for_hold->count, 1, '1 item for hold' ); + $builder->build_sample_item( { biblionumber => $biblio->biblionumber, notforloan => -1 } ); + is( $biblio->items->filter_by_for_hold->count, 2, '2 items for hold' ); + + $biblio->delete; +}; + # Reset nb_of_items prior to testing delete $nb_of_items = Koha::Items->search->count; -- 2.31.1