From fd4fa7c2d1355089a8150ebe95916eae2d3c0e0f Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Mon, 6 Apr 2026 11:48:15 +0000 Subject: [PATCH] Bug 41954: Update existing tests The logical behavior is different. Hold groups are now meant to be kept for historical reasons Signed-off-by: Bob Bennhoff Signed-off-by: Andrew Fuerste Henry Signed-off-by: Lucas Gass --- t/db_dependent/Koha/Hold.t | 4 ++-- t/db_dependent/Koha/Patron.t | 18 +++++++++++++----- t/db_dependent/Reserves/HoldGroup.t | 2 +- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/t/db_dependent/Koha/Hold.t b/t/db_dependent/Koha/Hold.t index f2ca996bf4..ef3ff78192 100755 --- a/t/db_dependent/Koha/Hold.t +++ b/t/db_dependent/Koha/Hold.t @@ -2085,8 +2085,8 @@ subtest 'is_hold_group_target, cleanup_hold_group and set_as_hold_group_target t $hold_2->cancel(); is( - $hold_3->hold_group, undef, - 'Third hold was left as the only member of its group. Group was deleted and the hold is no longer part of a hold group' + $hold_3->hold_group->hold_group_id, $new_hold_group->hold_group_id, + 'Third hold was left as the only member of its group. Group is kept and this hold is still part of it for historic reasons.' ); $schema->storage->txn_rollback; diff --git a/t/db_dependent/Koha/Patron.t b/t/db_dependent/Koha/Patron.t index b261210efe..8bc7fc6b1d 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 => 17; + plan tests => 19; $schema->storage->txn_begin; @@ -3643,7 +3643,7 @@ subtest "create_hold_group, hold_groups, visual_hold_group_id tests" => sub { is( $hold_group->hold_group_id, $hold3->get_from_storage->hold_group_id, 'hold3 added to hold_group' ); # Create 2nd hold group - $patron->create_hold_group( [ $hold4->reserve_id, $hold5->reserve_id ] ); + my $hg_to_be_kept = $patron->create_hold_group( [ $hold4->reserve_id, $hold5->reserve_id ] ); is( $patron_hold_groups->count, 2, 'Patron has two hold groups' ); my $second_hold_group = $patron->hold_groups->as_list->[1]; @@ -3658,13 +3658,21 @@ subtest "create_hold_group, hold_groups, visual_hold_group_id tests" => sub { ); $hold3->get_from_storage->fill(); - is( $patron->get_from_storage->hold_groups->count, 1, 'Patron only has one hold group again' ); + is( $patron->get_from_storage->hold_groups->count, 1, 'Patron only has one active hold group' ); + is( + $patron->get_from_storage->hold_groups->next->hold_group_id, $hg_to_be_kept->hold_group_id, + 'Patron only has one active hold group. The 2nd created' + ); $hold4->get_from_storage->cancel(); - is( $patron->get_from_storage->hold_groups->count, 0, 'Patron does not have any hold groups again' ); + is( $patron->get_from_storage->hold_groups->count, 1, 'Patron only has one active hold group' ); + is( + $patron->get_from_storage->hold_groups->next->hold_group_id, $hg_to_be_kept->hold_group_id, + 'Patron only has one active hold group. The 2nd created. It was kept because one hold was cancelled and one hold remains.' + ); # Create 3rd hold group - $patron->create_hold_group( [ $hold5->reserve_id, $hold6->reserve_id ] ); + $patron->create_hold_group( [ $hold5->reserve_id, $hold6->reserve_id ], 1 ); 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' ); diff --git a/t/db_dependent/Reserves/HoldGroup.t b/t/db_dependent/Reserves/HoldGroup.t index 883e672175..93506e7f98 100755 --- a/t/db_dependent/Reserves/HoldGroup.t +++ b/t/db_dependent/Reserves/HoldGroup.t @@ -125,7 +125,7 @@ subtest "target_hold_id tests" => sub { my $hold = Koha::Holds->find($reserve_id); is( $hold_group->get_from_storage->target_hold_id, $hold->reserve_id, 'target_hold_id is correct' ); $hold->fill(); - is( $hold_group->get_from_storage, undef, 'hold group no longer exists' ); + is( $hold_group->get_from_storage->hold_group_id, $hold->hold_group_id, 'hold_group is kept' ); $schema->storage->txn_rollback; };