From 1cec5f1f616b3125882a67663af8884df6fbc8ba Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 30 Aug 2024 11:34:36 +0000 Subject: [PATCH] Bug 37774: Unit tests Signed-off-by: Brendan Lawlor --- t/db_dependent/Reserves.t | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t index 14fb88d5cb..7ada7fd4df 100755 --- a/t/db_dependent/Reserves.t +++ b/t/db_dependent/Reserves.t @@ -1082,9 +1082,9 @@ subtest 'reserves.item_level_hold' => sub { }; -subtest 'MoveReserve additional test' => sub { +subtest 'MoveReserve additional tests' => sub { - plan tests => 4; + plan tests => 8; # Create the items and patrons we need my $biblio = $builder->build_sample_biblio(); @@ -1124,6 +1124,39 @@ subtest 'MoveReserve additional test' => sub { is($patron_2->holds->count, 0, "The 2nd patrons no longer has a hold"); is($patron_2->old_holds->next()->reserve_id, $reserve_2, "The 2nd patrons hold was filled and moved to old holds"); + # Confirm that if a patron has a hold on an item that violates hold policies the hold is still filled when issuing the item + Koha::CirculationRules->set_rule( + { + branchcode => undef, + itemtype => $itype->itemtype, + rule_name => 'holdallowed', + rule_value => 'not_allowed' + } + ); + MoveReserve( $item_1->itemnumber, $patron_1->borrowernumber ); + is( $patron_1->holds->count, 0, "The 1st patron no longer has a hold" ); + is( + $patron_1->old_holds->next()->reserve_id, $reserve_1, + "The 1st patrons hold was filled and moved to old holds even when item not holdable" + ); + + # Confirm that if a patron has a hold on a title and is issued an item that violates hold policies the hold is still filled + my $reserve_3 = AddReserve( + { + branchcode => $item_1->homebranch, + borrowernumber => $patron_1->borrowernumber, + biblionumber => $biblio->biblionumber, + priority => 1, + itemnumber => undef, + } + ); + MoveReserve( $item_1->itemnumber, $patron_1->borrowernumber ); + is( $patron_1->holds->count, 0, "The 1st patron no longer has a hold" ); + is( + $patron_1->old_holds->next()->reserve_id, $reserve_1, + "The 1st patrons hold was filled and moved to old holds even when item not holdable" + ); + }; subtest 'RevertWaitingStatus' => sub { -- 2.39.2