From aee3661ba346c2e4e43b2e7ccba3ad1d465f5bfb Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Thu, 16 Oct 2025 10:22:16 +0000 Subject: [PATCH] Bug 36360: Add tests prove t/db_dependent/Koha/Patrons.t Test plan, k-t-d: 1) Enable ILLModule 2) Create an ILL request for patron 'John', visit: /cgi-bin/koha/ill/ill-requests.pl?method=create&backend=Standard 3) Type 'John' and pick the only result. Set a type and library. Click 'Create'. 4) Go to patrons search and search for 'jo': /cgi-bin/koha/members/members-home.pl 5) Tick the checkbox for John and someone else from the list. Click 'Merge selected patrons' from the top toolbar 6) Select the other patron (not John) as the 'patron to keep'. Click Merge patrons. 7) Notice '1 Illrequest was merge' message shows. 8) Visit the ILL list table, visit: /cgi-bin/koha/ill/ill-requests.pl 9) Notice the ILL request now belongs to the other patron, not John (who no longer exists). Signed-off-by: Richard Bridgen --- t/db_dependent/Koha/Patrons.t | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t index 429a3373b4..3dfd3cc7de 100755 --- a/t/db_dependent/Koha/Patrons.t +++ b/t/db_dependent/Koha/Patrons.t @@ -2114,7 +2114,7 @@ subtest 'BorrowersLog and CardnumberLog tests' => sub { $schema->storage->txn_rollback; subtest 'Test Koha::Patrons::merge' => sub { - plan tests => 113; + plan tests => 118; my $schema = Koha::Database->new()->schema(); @@ -2302,6 +2302,20 @@ subtest 'Test Koha::Patrons::merge' => sub { }; + subtest 'ILL requests' => sub { + plan tests => 3; + + my $keep_patron = $builder->build_object( { class => 'Koha::Patrons' } ); + my $merge_patron = $builder->build_object( { class => 'Koha::Patrons' } ); + my $ill_request = $builder->build_sample_ill_request( { borrowernumber => $merge_patron->borrowernumber } ); + + is( $merge_patron->ill_requests->count, 1, 'Patron to be merged has 1 ILL request' ); + is( $keep_patron->ill_requests->count, 0, 'Patron to be kept has 0 ILL requests' ); + + $keep_patron->merge_with( [ $merge_patron->borrowernumber ] ); + is( $keep_patron->ill_requests->count, 1, 'Patron to be kept now has 1 ILL request' ); + }; + t::lib::Mocks::mock_preference( 'AnonymousPatron', '' ); $schema->storage->txn_rollback; }; -- 2.39.5