From e09b40ff1c04e09cab2ffa75ba31505c8b93a763 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Wed, 1 Apr 2026 15:39:09 +0000 Subject: [PATCH] Bug 41878: Add tests Run these and all other holds groups related tests: prove t/db_dependent/Koha/Patron.t prove t/db_dependent/api/v1/patrons_hold_groups.t prove t/db_dependent/Koha/Hold.t prove t/db_dependent/Reserves/HoldGroup.t Signed-off-by: Bob Bennhoff Signed-off-by: Andrew Fuerste Henry Signed-off-by: Lucas Gass --- t/db_dependent/Koha/Patron.t | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Patron.t b/t/db_dependent/Koha/Patron.t index 5840c2edd3..b261210efe 100755 --- a/t/db_dependent/Koha/Patron.t +++ b/t/db_dependent/Koha/Patron.t @@ -3585,7 +3585,7 @@ subtest 'reset_2fa() tests' => sub { subtest "create_hold_group, hold_groups, visual_hold_group_id tests" => sub { - plan tests => 13; + plan tests => 17; $schema->storage->txn_begin; @@ -3668,5 +3668,31 @@ subtest "create_hold_group, hold_groups, visual_hold_group_id tests" => sub { my $third_hold_group = $patron->hold_groups->as_list->[0]; is( $third_hold_group->visual_hold_group_id, 1, 'Visual hold group id is 1' ); + t::lib::Mocks::mock_preference( 'HoldsLog', 1 ); + my $new_hg = $patron->create_hold_group( [ $hold6->reserve_id, $hold5->reserve_id ], 1 ); + my $hg_id = $new_hg->hold_group_id; + my $create_log = $schema->resultset('ActionLog')->search( + { + module => 'HOLDS', + action => 'MODIFY', + object => $hold6->reserve_id, + }, + { order_by => { -desc => 'action_id' } } + )->first; + ok( $create_log, 'Log entry created for hold when added to a new group' ); + like( $create_log->info, qr/'hold_group_id' => $hg_id/, 'Log info contains hold_group_id change' ); + + $new_hg->delete; + my $delete_log = $schema->resultset('ActionLog')->search( + { + module => 'HOLDS', + action => 'MODIFY', + object => $hold6->reserve_id, + }, + { order_by => { -desc => 'action_id' } } + )->first; + ok( $delete_log, 'Log entry created for hold when group was deleted' ); + like( $delete_log->info, qr/'hold_group_id' => undef/, 'Log shows the old group ID was removed' ); + $schema->storage->txn_rollback; };