From ff6ee4057dc77de22ef4e96f85fd9b3e7b95be04 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Tue, 14 Jul 2026 09:28:25 +0000 Subject: [PATCH] Bug 43069: Add tests 1) Set system preference 'PatronDuplicateMatchingAddFields' to empty (no fields ticked) 2) Go to /cgi-bin/koha/members/memberentry.pl?op=add and fill in the mandatory fields for a brand new patron (one that definitely doesn't exist yet) 3) Click 'Save' 4) Notice you get the 'Duplicate patron record?' dialog, even though no patron like this exists 5) Apply the patch. Restart plack 6) Repeat steps 2-3 with another new patron 7) Confirm the patron is created fine this time, no false duplicate error 8) Also try setting 'PatronDuplicateMatchingAddFields' to a field (e.g. 'city') and submit a new patron with that field left blank - confirm no false duplicate there either 9) Run: prove t/db_dependent/Koha/Patrons.t Signed-off-by: David Nind Signed-off-by: Martin Renvoize Signed-off-by: Lucas Gass --- t/db_dependent/Koha/Patrons.t | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t index 9be48931fe..db23712491 100755 --- a/t/db_dependent/Koha/Patrons.t +++ b/t/db_dependent/Koha/Patrons.t @@ -3888,7 +3888,7 @@ subtest 'find_by_identifier() tests' => sub { }; subtest 'check_for_existing_matches' => sub { - plan tests => 5; + plan tests => 7; $schema->storage->txn_begin; @@ -3896,9 +3896,22 @@ subtest 'check_for_existing_matches' => sub { { class => 'Koha::Patrons', value => { firstname => 'John', surname => 'Smith', dateofbirth => '1980-01-01' } } ); + t::lib::Mocks::mock_preference( 'PatronDuplicateMatchingAddFields', '' ); + my $match_result = Koha::Patrons->check_for_existing_matches( + { firstname => 'Someone', surname => 'Else', dateofbirth => '1999-09-09' } ); + is( $match_result->{duplicate_found}, 0, 'No duplicate found when PatronDuplicateMatchingAddFields is empty' ); + + t::lib::Mocks::mock_preference( 'PatronDuplicateMatchingAddFields', 'city' ); + $match_result = Koha::Patrons->check_for_existing_matches( + { firstname => 'Someone', surname => 'Else', dateofbirth => '1999-09-09' } ); + is( + $match_result->{duplicate_found}, 0, + 'No duplicate found when none of the configured match fields are populated' + ); + t::lib::Mocks::mock_preference( 'PatronDuplicateMatchingAddFields', 'dateofbirth|firstname|surname' ); - my $match_result = Koha::Patrons->check_for_existing_matches( + $match_result = Koha::Patrons->check_for_existing_matches( { firstname => 'John', surname => 'Smith', dateofbirth => '1980-01-01' } ); is( $match_result->{duplicate_found}, 1, 'Duplicate found' ); is( $match_result->{matching_patrons}->next->borrowernumber, $patron->borrowernumber, 'Matching patron' );