|
Lines 20-26
Link Here
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
|
21 |
|
| 22 |
use Test::NoWarnings; |
22 |
use Test::NoWarnings; |
| 23 |
use Test::More tests => 46; |
23 |
use Test::More tests => 47; |
| 24 |
use Test::Warn; |
24 |
use Test::Warn; |
| 25 |
use Test::Exception; |
25 |
use Test::Exception; |
| 26 |
use Test::MockModule; |
26 |
use Test::MockModule; |
|
Lines 500-506
subtest 'renew_account' => sub {
Link Here
|
| 500 |
dt_from_string($retrieved_expiry_date), $a_year_later_minus_a_month, |
500 |
dt_from_string($retrieved_expiry_date), $a_year_later_minus_a_month, |
| 501 |
"$a_month_ago + 12 months must be $a_year_later_minus_a_month" |
501 |
"$a_month_ago + 12 months must be $a_year_later_minus_a_month" |
| 502 |
); |
502 |
); |
| 503 |
my $number_of_logs = $schema->resultset('ActionLog') |
503 |
my $number_of_logs = |
|
|
504 |
$schema->resultset('ActionLog') |
| 504 |
->search( { module => 'MEMBERS', action => 'RENEW', object => $retrieved_patron->borrowernumber } )->count; |
505 |
->search( { module => 'MEMBERS', action => 'RENEW', object => $retrieved_patron->borrowernumber } )->count; |
| 505 |
is( $number_of_logs, 1, 'With BorrowerLogs, Koha::Patron->renew_account should have logged' ); |
506 |
is( $number_of_logs, 1, 'With BorrowerLogs, Koha::Patron->renew_account should have logged' ); |
| 506 |
|
507 |
|
|
Lines 515-521
subtest 'renew_account' => sub {
Link Here
|
| 515 |
); |
516 |
); |
| 516 |
$retrieved_expiry_date = $retrieved_patron->dateexpiry; |
517 |
$retrieved_expiry_date = $retrieved_patron->dateexpiry; |
| 517 |
is( dt_from_string($retrieved_expiry_date), $a_year_later, "today + 12 months must be $a_year_later" ); |
518 |
is( dt_from_string($retrieved_expiry_date), $a_year_later, "today + 12 months must be $a_year_later" ); |
| 518 |
$number_of_logs = $schema->resultset('ActionLog') |
519 |
$number_of_logs = |
|
|
520 |
$schema->resultset('ActionLog') |
| 519 |
->search( { module => 'MEMBERS', action => 'RENEW', object => $retrieved_patron->borrowernumber } )->count; |
521 |
->search( { module => 'MEMBERS', action => 'RENEW', object => $retrieved_patron->borrowernumber } )->count; |
| 520 |
is( $number_of_logs, 1, 'Without BorrowerLogs, Koha::Patron->renew_account should not have logged' ); |
522 |
is( $number_of_logs, 1, 'Without BorrowerLogs, Koha::Patron->renew_account should not have logged' ); |
| 521 |
|
523 |
|
|
Lines 650-656
subtest "delete" => sub {
Link Here
|
| 650 |
q|Koha::Patron->delete should have deleted patron's modifications| |
652 |
q|Koha::Patron->delete should have deleted patron's modifications| |
| 651 |
); |
653 |
); |
| 652 |
|
654 |
|
| 653 |
my $number_of_logs = $schema->resultset('ActionLog') |
655 |
my $number_of_logs = |
|
|
656 |
$schema->resultset('ActionLog') |
| 654 |
->search( { module => 'MEMBERS', action => 'DELETE', object => $patron->borrowernumber } )->count; |
657 |
->search( { module => 'MEMBERS', action => 'DELETE', object => $patron->borrowernumber } )->count; |
| 655 |
is( $number_of_logs, 1, 'With BorrowerLogs, Koha::Patron->delete should have logged' ); |
658 |
is( $number_of_logs, 1, 'With BorrowerLogs, Koha::Patron->delete should have logged' ); |
| 656 |
|
659 |
|
|
Lines 2468-2474
subtest '->set_password' => sub {
Link Here
|
| 2468 |
ok( checkpw_hash( 'abcd a', $patron->password ), 'Password hash is correct' ); |
2471 |
ok( checkpw_hash( 'abcd a', $patron->password ), 'Password hash is correct' ); |
| 2469 |
is( $patron->login_attempts, 0, 'Login attempts have been reset' ); |
2472 |
is( $patron->login_attempts, 0, 'Login attempts have been reset' ); |
| 2470 |
|
2473 |
|
| 2471 |
my $number_of_logs = $schema->resultset('ActionLog') |
2474 |
my $number_of_logs = |
|
|
2475 |
$schema->resultset('ActionLog') |
| 2472 |
->search( { module => 'MEMBERS', action => 'CHANGE PASS', object => $patron->borrowernumber } )->count; |
2476 |
->search( { module => 'MEMBERS', action => 'CHANGE PASS', object => $patron->borrowernumber } )->count; |
| 2473 |
is( $number_of_logs, 0, 'Without BorrowerLogs, Koha::Patron->set_password doesn\'t log password changes' ); |
2477 |
is( $number_of_logs, 0, 'Without BorrowerLogs, Koha::Patron->set_password doesn\'t log password changes' ); |
| 2474 |
|
2478 |
|
|
Lines 3574-3577
subtest 'filter_by_expired_opac_registrations' => sub {
Link Here
|
| 3574 |
$schema->storage->txn_rollback; |
3578 |
$schema->storage->txn_rollback; |
| 3575 |
}; |
3579 |
}; |
| 3576 |
|
3580 |
|
|
|
3581 |
subtest 'find_by_identifier() tests' => sub { |
| 3582 |
|
| 3583 |
plan tests => 7; |
| 3584 |
|
| 3585 |
$schema->storage->txn_begin; |
| 3586 |
|
| 3587 |
# Create test patrons with specific userid and cardnumber |
| 3588 |
my $patron_1 = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 3589 |
my $patron_2 = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 3590 |
|
| 3591 |
# Create a patron to delete to |
| 3592 |
my $to_delete = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 3593 |
my $ne_userid = $to_delete->userid; |
| 3594 |
my $ne_cardnumber = $to_delete->cardnumber; |
| 3595 |
$to_delete->delete(); |
| 3596 |
|
| 3597 |
# Test finding by userid |
| 3598 |
my $found_patron = Koha::Patrons->find_by_identifier( $patron_1->userid ); |
| 3599 |
is( $found_patron->id, $patron_1->id, 'Found patron by userid' ); |
| 3600 |
|
| 3601 |
# Test finding by cardnumber |
| 3602 |
$found_patron = Koha::Patrons->find_by_identifier( $patron_1->cardnumber ); |
| 3603 |
is( $found_patron->id, $patron_1->id, 'Found patron by cardnumber' ); |
| 3604 |
|
| 3605 |
# Test finding by cardnumber when userid doesn't match |
| 3606 |
$found_patron = Koha::Patrons->find_by_identifier( $patron_2->cardnumber ); |
| 3607 |
is( $found_patron->id, $patron_2->id, 'Found patron by cardnumber when userid differs' ); |
| 3608 |
|
| 3609 |
# Test with non-existent identifiers |
| 3610 |
$found_patron = Koha::Patrons->find_by_identifier($ne_cardnumber); |
| 3611 |
is( $found_patron, undef, 'Returns undef for non-existent identifier' ); |
| 3612 |
$found_patron = Koha::Patrons->find_by_identifier($ne_userid); |
| 3613 |
is( $found_patron, undef, 'Returns undef for non-existent identifier' ); |
| 3614 |
|
| 3615 |
# Test with empty identifier |
| 3616 |
$found_patron = Koha::Patrons->find_by_identifier(''); |
| 3617 |
is( $found_patron, undef, 'Returns undef for empty identifier' ); |
| 3618 |
|
| 3619 |
# Test with undef identifier |
| 3620 |
$found_patron = Koha::Patrons->find_by_identifier(undef); |
| 3621 |
is( $found_patron, undef, 'Returns undef for undef identifier' ); |
| 3622 |
|
| 3623 |
$schema->storage->txn_rollback; |
| 3624 |
}; |
| 3625 |
|
| 3577 |
$schema->storage->txn_rollback; |
3626 |
$schema->storage->txn_rollback; |
| 3578 |
- |
|
|