From 8383009cc64698a4a0f28255702075e200ef2a98 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 25 Aug 2020 10:35:02 +0000 Subject: [PATCH] Bug 18958: (follow-up) Ensure hold fill target reserve_id is set for all hold types MapItemsToHoldRequests has three sections: Local holds, item level holds, bib level holds Only one of them was setting the reserve_id. This patch makes al three set it and adds tests To test: 1 - Repeat test plan on bug 2 - sudo koha-mysql kohadev SELECT * FROM hold_fill_targets 3 - Ensure reserve_id is set at appropriate times 4 - prove -v t/db_dependent/HoldsQueue.t Signed-off-by: Marcel de Rooy Bug 18958: (QA follow-up) Fix number of tests In HoldsQueue.t Signed-off-by: Marcel de Rooy Signed-off-by: Jonathan Druart Signed-off-by: Jonathan Druart (cherry picked from commit b255ca7c6eec7be3027e6ade00d8477102062281) Signed-off-by: Lucas Gass (cherry picked from commit bac2e6892a817482f14249aceb1420c2700416d6) Signed-off-by: Aleisha Amohia --- C4/HoldsQueue.pm | 2 ++ t/db_dependent/HoldsQueue.t | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/C4/HoldsQueue.pm b/C4/HoldsQueue.pm index 2a017ed1cb..a614b416d9 100755 --- a/C4/HoldsQueue.pm +++ b/C4/HoldsQueue.pm @@ -481,6 +481,7 @@ sub MapItemsToHoldRequests { biblionumber => $request->{biblionumber}, holdingbranch => $items_by_itemnumber{ $request->{itemnumber} }->{holdingbranch}, pickup_branch => $request->{branchcode} || $request->{borrowerbranch}, + reserve_id => $request->{reserve_id}, item_level => $request->{item_level_hold}, reservedate => $request->{reservedate}, reservenotes => $request->{reservenotes}, @@ -656,6 +657,7 @@ sub MapItemsToHoldRequests { biblionumber => $request->{biblionumber}, holdingbranch => $holdingbranch, pickup_branch => $pickup_branch, + reserve_id => $request->{reserve_id}, item_level => $request->{item_level_hold}, reservedate => $request->{reservedate}, reservenotes => $request->{reservenotes}, diff --git a/t/db_dependent/HoldsQueue.t b/t/db_dependent/HoldsQueue.t index af22c864dd..cd8f6c634b 100755 --- a/t/db_dependent/HoldsQueue.t +++ b/t/db_dependent/HoldsQueue.t @@ -8,7 +8,7 @@ use Modern::Perl; -use Test::More tests => 53; +use Test::More tests => 55; use Data::Dumper; use C4::Calendar; @@ -637,6 +637,8 @@ $reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 ); C4::HoldsQueue::CreateQueue(); $holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } ); is( @$holds_queue, 1, "Hold where pickup branch matches home branch targeted" ); +my $target_rs = $schema->resultset('HoldFillTarget'); +is( $target_rs->next->reserve_id, $reserve_id, "Reserve id correctly set in hold fill target for title level hold" ); Koha::Holds->find( $reserve_id )->cancel; # Holding branch matches pickup branch @@ -795,7 +797,7 @@ Koha::Holds->find( $reserve_id )->cancel; subtest "Test Local Holds Priority - Bib level" => sub { - plan tests => 2; + plan tests => 3; Koha::Biblios->delete(); t::lib::Mocks::mock_preference( 'LocalHoldsPriority', 1 ); @@ -837,6 +839,7 @@ subtest "Test Local Holds Priority - Bib level" => sub { C4::HoldsQueue::CreateQueue(); my $queue_rs = $schema->resultset('TmpHoldsqueue'); + my $target_rs = $schema->resultset('HoldFillTarget'); is( $queue_rs->count(), 1, "Hold queue contains one hold" ); is( @@ -844,6 +847,7 @@ subtest "Test Local Holds Priority - Bib level" => sub { $local_patron->borrowernumber, "We should pick the local hold over the next available" ); + is( $target_rs->next->reserve_id, $reserve_id2, "Reserve id correctly set in hold fill target" ); }; subtest "Test Local Holds Priority - Item level" => sub { @@ -1075,7 +1079,7 @@ subtest "Test Local Holds Priority - Ensure no duplicate requests in holds queue subtest "Item level holds info is preserved (Bug 25783)" => sub { - plan tests => 3; + plan tests => 4; $dbh->do("DELETE FROM tmp_holdsqueue"); $dbh->do("DELETE FROM hold_fill_targets"); @@ -1128,6 +1132,8 @@ subtest "Item level holds info is preserved (Bug 25783)" => sub { my $queue_line_1 = $queue_rs->next; is( $queue_line_1->item_level_request, 1, 'Request is correctly advertised as item-level' ); + my $target_rs = $schema->resultset('HoldFillTarget')->search({borrowernumber=>$patron_1->borrowernumber});; + is( $target_rs->next->reserve_id, $reserve_id_1, "Reserve id correctly set in hold fill target for item level hold" ); my $queue_line_2 = $queue_rs->next; is( $queue_line_2->item_level_request, 0, 'Request is correctly advertised as biblio-level' ); -- 2.39.5