|
Lines 19-25
Link Here
|
| 19 |
|
19 |
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
|
21 |
|
| 22 |
use Test::More tests => 34; |
22 |
use Test::More tests => 33; |
| 23 |
use Test::Warn; |
23 |
use Test::Warn; |
| 24 |
use Test::Exception; |
24 |
use Test::Exception; |
| 25 |
use Test::MockModule; |
25 |
use Test::MockModule; |
|
Lines 208-238
subtest 'has_overdues' => sub {
Link Here
|
| 208 |
$issue->delete(); |
208 |
$issue->delete(); |
| 209 |
}; |
209 |
}; |
| 210 |
|
210 |
|
| 211 |
subtest 'update_password' => sub { |
|
|
| 212 |
plan tests => 7; |
| 213 |
|
| 214 |
t::lib::Mocks::mock_preference( 'BorrowersLog', 1 ); |
| 215 |
my $original_userid = $new_patron_1->userid; |
| 216 |
my $original_password = $new_patron_1->password; |
| 217 |
warning_like { $retrieved_patron_1->update_password( $new_patron_2->userid, 'another_password' ) } |
| 218 |
qr{Duplicate entry}, |
| 219 |
'Koha::Patron->update_password should warn if the userid is already used by another patron'; |
| 220 |
is( Koha::Patrons->find( $new_patron_1->borrowernumber )->userid, $original_userid, 'Koha::Patron->update_password should not have updated the userid' ); |
| 221 |
is( Koha::Patrons->find( $new_patron_1->borrowernumber )->password, $original_password, 'Koha::Patron->update_password should not have updated the userid' ); |
| 222 |
|
| 223 |
my $digest = $retrieved_patron_1->update_password( 'another_nonexistent_userid_1', 'another_password' ); |
| 224 |
is( Koha::Patrons->find( $new_patron_1->borrowernumber )->userid, 'another_nonexistent_userid_1', 'Koha::Patron->update_password should have updated the userid' ); |
| 225 |
is( Koha::Patrons->find( $new_patron_1->borrowernumber )->password, $digest, 'Koha::Patron->update_password should have updated the password' ); |
| 226 |
|
| 227 |
my $number_of_logs = $schema->resultset('ActionLog')->search( { module => 'MEMBERS', action => 'CHANGE PASS', object => $new_patron_1->borrowernumber } )->count; |
| 228 |
is( $number_of_logs, 1, 'With BorrowerLogs, Koha::Patron->update_password should have logged' ); |
| 229 |
|
| 230 |
t::lib::Mocks::mock_preference( 'BorrowersLog', 0 ); |
| 231 |
$retrieved_patron_1->update_password( 'yet_another_nonexistent_userid_1', 'another_password' ); |
| 232 |
$number_of_logs = $schema->resultset('ActionLog')->search( { module => 'MEMBERS', action => 'CHANGE PASS', object => $new_patron_1->borrowernumber } )->count; |
| 233 |
is( $number_of_logs, 1, 'With BorrowerLogs, Koha::Patron->update_password should not have logged' ); |
| 234 |
}; |
| 235 |
|
| 236 |
subtest 'is_expired' => sub { |
211 |
subtest 'is_expired' => sub { |
| 237 |
plan tests => 4; |
212 |
plan tests => 4; |
| 238 |
my $patron = $builder->build({ source => 'Borrower' }); |
213 |
my $patron = $builder->build({ source => 'Borrower' }); |
| 239 |
- |
|
|