From 35dc09a6ae1438e1a6d0b50ebf1f4ed0eba3a88e Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 10 Feb 2026 11:46:12 -0500 Subject: [PATCH] Bug 41552: Add unit tests --- t/db_dependent/HoldsQueue.t | 55 ++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/HoldsQueue.t b/t/db_dependent/HoldsQueue.t index b4db63abfe3..ace1c3a3986 100755 --- a/t/db_dependent/HoldsQueue.t +++ b/t/db_dependent/HoldsQueue.t @@ -9,7 +9,7 @@ use Modern::Perl; use Test::NoWarnings; -use Test::More tests => 65; +use Test::More tests => 66; use Data::Dumper; use C4::Calendar; @@ -2534,3 +2534,56 @@ subtest "Test unallocated option" => sub { "Previously allocated hold not updated when unallocated passed and others are allocated" ); }; + +subtest "Suspended holds should be removed from the holds queue" => sub { + + plan tests => 2; + + $schema->storage->txn_begin; + + t::lib::Mocks::mock_preference( 'LocalHoldsPriority', 'None' ); + 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)->suspend_hold(); + + is( + $rs->search( { biblionumber => $biblio->biblionumber } )->count, 0, + "Hold is no longer found in the holds queue after suspension" + ); + + $schema->storage->txn_rollback; +}; -- 2.50.1 (Apple Git-155)