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:
<staff_url>/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':
<staff_url>/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:
<staff_url>/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 <richard.bridgen@nhs.net>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 9c9ba87468)
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
This commit is contained in:
Pedro Amorim 2025-10-16 10:22:16 +00:00 committed by Jacob O'Mara
parent f5cb49b5d0
commit bc347e8cf3
No known key found for this signature in database
1 changed files with 15 additions and 1 deletions

View File

@ -2118,7 +2118,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();
@ -2306,6 +2306,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;
};