From 4e243d21d65c712ab35954c8fa071f1d2dad878d Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 6 Feb 2024 12:11:12 -0500 Subject: [PATCH] Bug 35357: Enhance unit tests Signed-off-by: Victor Grousset/tuxayo --- t/db_dependent/HoldsQueue.t | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/t/db_dependent/HoldsQueue.t b/t/db_dependent/HoldsQueue.t index 8fb0b94c4c..39c6b3ab3a 100755 --- a/t/db_dependent/HoldsQueue.t +++ b/t/db_dependent/HoldsQueue.t @@ -2095,7 +2095,7 @@ subtest "GetItemsAvailableToFillHoldsRequestsForBib" => sub { subtest 'Remove item from holds queue on checkout' => sub { - plan tests => 2; + plan tests => 4; $schema->storage->txn_begin; @@ -2114,7 +2114,9 @@ subtest 'Remove item from holds queue on checkout' => sub { } ); - my $item = $builder->build_sample_item( { homebranch => $lib->branchcode, holdingbranch => $lib->branchcode } ); + my $item = $builder->build_sample_item( { homebranch => $lib->branchcode, holdingbranch => $lib->branchcode } ); + my $item2 = $builder->build_sample_item( + { homebranch => $lib->branchcode, holdingbranch => $lib->branchcode, biblionumber => $item->biblionumber } ); t::lib::Mocks::mock_userenv( { branchcode => $lib->branchcode } ); @@ -2132,15 +2134,27 @@ subtest 'Remove item from holds queue on checkout' => sub { is( Koha::Hold::HoldsQueueItems->search( { itemnumber => $item->id } )->count(), 1, - "Item is found in the holds queue" + "One item is found in the holds queue" ); - AddIssue( $patron1, $item->barcode, dt_from_string ); + my $hq_item = Koha::Hold::HoldsQueueItems->search( { itemnumber => $item->id } )->next->item; + + AddIssue( $patron1, $hq_item->barcode, dt_from_string ); is( Koha::Hold::HoldsQueueItems->search( { itemnumber => $item->id } )->count(), 0, "Item is no longer found in the holds queue" ); + C4::HoldsQueue::CreateQueue(); + + is( + Koha::Hold::HoldsQueueItems->search( { itemnumber => $item2->id } )->count(), 1, + "One item is found in the holds queue" + ); + + my $hq_item2 = Koha::Hold::HoldsQueueItems->search( { itemnumber => $item2->id } )->next->item; + isnt( $hq_item->id, $hq_item2->id, "Item now targetd by the holds queue is not the same item." ); + $schema->storage->txn_rollback; }; -- 2.43.0