From 29fd20e0684da021ca8804f931141f508bcdd103 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 11 Jan 2024 09:25:26 -0500 Subject: [PATCH] Bug 35357: Add unit test Signed-off-by: Owen Leonard Signed-off-by: Victor Grousset/tuxayo Signed-off-by: Katrin Fischer (cherry picked from commit 0e11bc0de539692e1ed856a36e6faf4f30335eed) Signed-off-by: Fridolin Somers --- t/db_dependent/HoldsQueue.t | 50 ++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/HoldsQueue.t b/t/db_dependent/HoldsQueue.t index 7875c69eed..6bb0d8f0c1 100755 --- a/t/db_dependent/HoldsQueue.t +++ b/t/db_dependent/HoldsQueue.t @@ -8,7 +8,7 @@ use Modern::Perl; -use Test::More tests => 61; +use Test::More tests => 62; use Data::Dumper; use C4::Calendar qw( new insert_single_holiday ); @@ -2090,4 +2090,52 @@ subtest "GetItemsAvailableToFillHoldsRequestsForBib" => sub { is( scalar @$items, 2, "Two items without active transfers correctly retrieved"); is_deeply( [$items->[0]->{itemnumber},$items->[1]->{itemnumber}],[$item_2->itemnumber,$item_3->itemnumber],"Correct two items retrieved"); + $schema->storage->txn_rollback; +}; + +subtest 'Remove item from holds queue on checkout' => sub { + + plan tests => 2; + + $schema->storage->txn_begin; + + my $lib = $builder->build_object( { class => 'Koha::Libraries' } ); + + my $patron1 = $builder->build_object( + { + class => 'Koha::Patrons', + value => { branchcode => $lib->branchcode } + } + ); + my $patron2 = $builder->build_object( + { + class => 'Koha::Patrons', + value => { branchcode => $lib->branchcode } + } + ); + + my $item = $builder->build_sample_item( + { homebranch => $lib->branchcode, holdingbranch => $lib->branchcode } ); + + t::lib::Mocks::mock_userenv( { branchcode => $lib->branchcode } ); + + my $hold_id = AddReserve( + { + branchcode => $item->homebranch, + borrowernumber => $patron2->borrowernumber, + biblionumber => $item->biblionumber, + itemnumber => undef, + priority => 1 + } + ); + + C4::HoldsQueue::CreateQueue(); + + is( Koha::Hold::HoldsQueueItems->search({ itemnumber => $item->id })->count(), 1, "Item is found in the holds queue" ); + + AddIssue( $patron1, $item->barcode, dt_from_string ); + + is( Koha::Hold::HoldsQueueItems->search({ itemnumber => $item->id })->count(), 0, "Item is no longer found in the holds queue" ); + + $schema->storage->txn_rollback; }; -- 2.20.1