From 0a38e190895bf1035416a300f25d348a5513c29d Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 5 Feb 2024 14:44:46 -0500 Subject: [PATCH] Bug 35997: Add tests Content-Type: text/plain; charset=utf-8 Test plan: see next patch Signed-off-by: Brendan Lawlor Signed-off-by: Victor Grousset/tuxayo --- t/db_dependent/HoldsQueue.t | 53 +++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/t/db_dependent/HoldsQueue.t b/t/db_dependent/HoldsQueue.t index addcee50a1..6ed73340f6 100755 --- a/t/db_dependent/HoldsQueue.t +++ b/t/db_dependent/HoldsQueue.t @@ -2158,3 +2158,56 @@ subtest 'Remove item from holds queue on checkout' => sub { $schema->storage->txn_rollback; }; + +subtest "Canceled holds should be removed from the holds queue" => sub { + + plan tests => 2; + + $schema->storage->txn_begin; + + t::lib::Mocks::mock_preference( 'LocalHoldsPriority', 0 ); + t::lib::Mocks::mock_preference( 'UseTransportCostMatrix', 0 ); + + my $branch1 = $builder->build_object( { class => 'Koha::Libraries' } ); + my $category = $builder->build_object( { class => 'Koha::Patron::Categories' } ); + my $patron = $builder->build_object( + { + class => "Koha::Patrons", + value => { + branchcode => $branch1->branchcode, + categorycode => $category->categorycode + } + } + ); + + my $biblio = $builder->build_sample_biblio(); + my $item1 = $builder->build_sample_item( + { + biblionumber => $biblio->biblionumber, + library => $branch1->branchcode, + } + ); + + my $reserve_id = AddReserve( + { + branchcode => $branch1->branchcode, + borrowernumber => $patron->borrowernumber, + biblionumber => $biblio->biblionumber, + priority => 1, + } + ); + + C4::HoldsQueue::CreateQueue(); + my $rs = $schema->resultset('TmpHoldsqueue'); + + is( $rs->search( { biblionumber => $biblio->biblionumber } )->count, 1, "Found the hold in the holds queue" ); + + Koha::Holds->find($reserve_id)->cancel(); + + is( + $rs->search( { biblionumber => $biblio->biblionumber } )->count, 0, + "Hold is no longer found in the holds queue after cancellation" + ); + + $schema->storage->txn_rollback; +}; -- 2.30.2