From dd4818cacf80959e10bcfc137e2e127e5fbc1bc5 Mon Sep 17 00:00:00 2001 From: Arthur Suzuki Date: Thu, 15 Oct 2020 08:43:47 +0200 Subject: [PATCH] Bug 25408: More test (with staff context) --- t/db_dependent/Reserves.t | 49 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t index c5b11d3cb8..9919264995 100755 --- a/t/db_dependent/Reserves.t +++ b/t/db_dependent/Reserves.t @@ -918,7 +918,7 @@ subtest 'ChargeReserveFee tests' => sub { }; subtest 'reserves.item_level_hold' => sub { - plan tests => 3; + plan tests => 4; my $item = $builder->build_sample_item; my $patron = $builder->build_object( @@ -1074,6 +1074,53 @@ subtest 'reserves.item_level_hold' => sub { is( $canreserve->{status}, 'OK', 'item-level holds should be possible with opacitemholds set to "Yes"' ); }; + + subtest 'test opacitemholds rules in staff context' => sub { + plan tests => 2; + + Koha::CirculationRules->set_rules( + { + branchcode => undef, + categorycode => undef, + itemtype => undef, + rules => { + reservesallowed => 25, + opacitemholds => 'N', + } + } + ); + + my $canreserve = C4::Reserves::CanBookBeReserved( + $patron->borrowernumber, + $item->biblionumber, + undef, + { context => 'staff' } + ); + + is( $canreserve->{status}, 'OK', + 'record-level holds should be possible with opacitemholds set to "No"' ); + + $canreserve = C4::Reserves::CanItemBeReserved( + $patron->borrowernumber, + $item->itemnumber, + undef, + { context => 'staff' } + ); + + is( $canreserve->{status}, 'OK', + 'item-level holds should still be possible in staff context, even with opacitemholds set to "No"' ); + }; + + Koha::CirculationRules->set_rules( + { + branchcode => undef, + categorycode => undef, + itemtype => undef, + rules => { + opacitemholds => undef, + } + } + ); }; subtest 'MoveReserve additional test' => sub { -- 2.11.0