From 6225105a26cb0f1287389de2fdf8323f25822368 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 2 Nov 2023 12:59:03 +0000 Subject: [PATCH] Bug 21431: Add unit test Content-Type: text/plain; charset=utf-8 Test plan: Run t/db_dependent/Koha/Patrons.t Signed-off-by: Marcel de Rooy --- t/db_dependent/Koha/Patrons.t | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t index a9df49df55..85a1159fcd 100755 --- a/t/db_dependent/Koha/Patrons.t +++ b/t/db_dependent/Koha/Patrons.t @@ -1921,7 +1921,7 @@ subtest '->store' => sub { subtest '->set_password' => sub { - plan tests => 16; + plan tests => 17; t::lib::Mocks::mock_preference( 'EmailFieldPrecedence', 'emailpro|email' ); @@ -1994,10 +1994,25 @@ subtest '->set_password' => sub { # Enable logging password changes t::lib::Mocks::mock_preference( 'BorrowersLog', 1 ); - $patron->set_password({ password => 'abcd b' }); - - $number_of_logs = $schema->resultset('ActionLog')->search( { module => 'MEMBERS', action => 'CHANGE PASS', object => $patron->borrowernumber } )->count; + $patron->set_password( { password => 'abcd b' } ); + $number_of_logs = $schema->resultset('ActionLog')->search( + { + module => 'MEMBERS', + action => 'CHANGE PASS', + object => $patron->borrowernumber + } + )->count; is( $number_of_logs, 1, 'With BorrowerLogs, Koha::Patron->set_password does log password changes' ); + # add other action name + $patron->set_password( { password => 'abcd b2', action => 'RESET PASS' } ); + $number_of_logs = $schema->resultset('ActionLog')->search( + { + module => 'MEMBERS', + action => 'RESET PASS', + object => $patron->borrowernumber + } + )->count; + is( $number_of_logs, 1, 'set_password allows another action name' ); # Enable notifying patrons of password changes t::lib::Mocks::mock_preference( 'NotifyPasswordChange', 1 ); -- 2.30.2