From 133267e18f10c2dba6dbaa69124bda8919b63f69 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Wed, 30 Aug 2023 18:54:15 +0000 Subject: [PATCH] Bug 34666: Add a second unit test for item level Signed-off-by: David Nind Signed-off-by: Marcel de Rooy Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 6f7ccdf6c3d4916ac19b7ace58068ff862a5ee24) Signed-off-by: Fridolin Somers (cherry picked from commit 91d9a154850a7a2fa9a1d233c555262a01ecef18) Signed-off-by: Matt Blenkinsop --- t/db_dependent/Reserves.t | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t index 1b5e5004c0..e6be96bd8c 100755 --- a/t/db_dependent/Reserves.t +++ b/t/db_dependent/Reserves.t @@ -1779,12 +1779,13 @@ subtest 'DefaultHoldExpiration tests' => sub { }; subtest '_Findgroupreserves' => sub { - plan tests => 1; + plan tests => 4; $schema->storage->txn_begin; my $patron_1 = $builder->build_object( { class => 'Koha::Patrons' } ); my $patron_2 = $builder->build_object( { class => 'Koha::Patrons' } ); my $item = $builder->build_sample_item(); + my $item_2 = $builder->build_sample_item( { biblionumber => $item->biblionumber } ); t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 ); my $reserve_id_1 = AddReserve( @@ -1813,6 +1814,22 @@ subtest '_Findgroupreserves' => sub { # When the hold is title level and in the hold fill targets we expect this to be the only hold returned my @reserves = C4::Reserves::_Findgroupreserve( $item->biblionumber, $item->id, 0, [] ); - is( scalar @reserves, 1, "We should only get the hold that is in the map" ); + is( scalar @reserves, 1, "We should only get the hold that is in the map" ); + is( $reserves[0]->{reserve_id}, $reserve_id_1, "We got the expected reserve" ); + + C4::HoldsQueue::AddToHoldTargetMap( + { + $item_2->id => { + borrowernumber => $patron_2->id, biblionumber => $item->biblionumber, + holdingbranch => $item->holdingbranch, item_level => 1, reserve_id => $reserve_id_2 + } + } + ); + + # When the hold is title level and in the hold fill targets we expect this to be the only hold returned + @reserves = C4::Reserves::_Findgroupreserve( $item->biblionumber, $item_2->id, 0, [] ); + is( scalar @reserves, 1, "We should only get the item level hold that is in the map" ); + is( $reserves[0]->{reserve_id}, $reserve_id_2, "We got the expected reserve" ); + $schema->txn_rollback; }; -- 2.39.2