From 91c5303e2fc69b0755024c7d9cee79006ed41720 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Fri, 8 Oct 2021 09:10:22 +0000 Subject: [PATCH] Bug 3142: (QA follow-up) Include notforloan itemtypes As was done in the code already. Note that we are ignoring effective itemtype now. Signed-off-by: Marcel de Rooy Signed-off-by: Nick Clemens Signed-off-by: Jonathan Druart (cherry picked from commit 05ddd7eede98f30368ab4debf4ac389c4b3ad13d) Signed-off-by: Andrew Fuerste-Henry --- Koha/Items.pm | 1 + t/db_dependent/Koha/Items.t | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Koha/Items.pm b/Koha/Items.pm index 87b5a38b64..9c46ef936e 100644 --- a/Koha/Items.pm +++ b/Koha/Items.pm @@ -60,6 +60,7 @@ sub filter_by_for_hold { rule_value => 'not_allowed', } )->get_column('itemtype'); + push @hold_not_allowed_itypes, Koha::ItemTypes->search({ notforloan => 1 })->get_column('itemtype'); return $self->search( { diff --git a/t/db_dependent/Koha/Items.t b/t/db_dependent/Koha/Items.t index b9ea036efe..6aff277497 100755 --- a/t/db_dependent/Koha/Items.t +++ b/t/db_dependent/Koha/Items.t @@ -1471,7 +1471,7 @@ subtest 'can_be_transferred' => sub { }; subtest 'filter_by_for_hold' => sub { - plan tests => 9; + plan tests => 11; my $biblio = $builder->build_sample_biblio; is( $biblio->items->filter_by_for_hold->count, 0, 'no item yet' ); @@ -1497,7 +1497,8 @@ subtest 'filter_by_for_hold' => sub { t::lib::Mocks::mock_preference('AllowHoldsOnDamagedItems', 1); is( $biblio->items->filter_by_for_hold->count, 6, '6 items for hold - damaged if AllowHoldsOnDamagedItems' ); - my $not_holdable_itemtype = $builder->build_object({ class => 'Koha::ItemTypes' })->itemtype; + my $itemtype = $builder->build_object({ class => 'Koha::ItemTypes' }); + my $not_holdable_itemtype = $itemtype->itemtype; $builder->build_sample_item( { biblionumber => $biblio->biblionumber, @@ -1514,6 +1515,19 @@ subtest 'filter_by_for_hold' => sub { ); is( $biblio->items->filter_by_for_hold->count, 6, '6 items for hold - holdallowed=not_allowed' ); + # Remove rule, test notforloan on itemtype + Koha::CirculationRules->set_rule( + { + branchcode => undef, + itemtype => $not_holdable_itemtype, + rule_name => 'holdallowed', + rule_value => undef, + } + ); + is( $biblio->items->filter_by_for_hold->count, 7, '7 items for hold - rule deleted' ); + $itemtype->notforloan(1)->store; + is( $biblio->items->filter_by_for_hold->count, 6, '6 items for hold - notforloan' ); + $biblio->delete; }; -- 2.39.5