View | Details | Raw Unified | Return to bug 17699
Collapse All | Expand All

(-)a/t/db_dependent/Koha/Patrons.t (-9 / +8 lines)
Lines 292-322 subtest 'renew_account' => sub { Link Here
292
        t::lib::Mocks::mock_preference( 'BorrowerRenewalPeriodBase', 'dateexpiry' );
292
        t::lib::Mocks::mock_preference( 'BorrowerRenewalPeriodBase', 'dateexpiry' );
293
        t::lib::Mocks::mock_preference( 'BorrowersLog',              1 );
293
        t::lib::Mocks::mock_preference( 'BorrowersLog',              1 );
294
        my $expiry_date = $retrieved_patron->renew_account;
294
        my $expiry_date = $retrieved_patron->renew_account;
295
        is( $expiry_date, $a_year_later_minus_a_month, );
295
        is( $expiry_date, $a_year_later_minus_a_month, "$a_month_ago + 12 months must be $a_year_later_minus_a_month" );
296
        my $retrieved_expiry_date = Koha::Patrons->find( $patron->{borrowernumber} )->dateexpiry;
296
        my $retrieved_expiry_date = Koha::Patrons->find( $patron->{borrowernumber} )->dateexpiry;
297
        is( dt_from_string($retrieved_expiry_date), $a_year_later_minus_a_month );
297
        is( dt_from_string($retrieved_expiry_date), $a_year_later_minus_a_month, "$a_month_ago + 12 months must be $a_year_later_minus_a_month" );
298
        my $number_of_logs = $schema->resultset('ActionLog')->search( { module => 'MEMBERS', action => 'RENEW', object => $retrieved_patron->borrowernumber } )->count;
298
        my $number_of_logs = $schema->resultset('ActionLog')->search( { module => 'MEMBERS', action => 'RENEW', object => $retrieved_patron->borrowernumber } )->count;
299
        is( $number_of_logs, 1, 'With BorrowerLogs, Koha::Patron->renew_account should have logged' );
299
        is( $number_of_logs, 1, 'With BorrowerLogs, Koha::Patron->renew_account should have logged' );
300
300
301
        t::lib::Mocks::mock_preference( 'BorrowerRenewalPeriodBase', 'now' );
301
        t::lib::Mocks::mock_preference( 'BorrowerRenewalPeriodBase', 'now' );
302
        t::lib::Mocks::mock_preference( 'BorrowersLog',              0 );
302
        t::lib::Mocks::mock_preference( 'BorrowersLog',              0 );
303
        $expiry_date = $retrieved_patron->renew_account;
303
        $expiry_date = $retrieved_patron->renew_account;
304
        is( $expiry_date, $a_year_later, );
304
        is( $expiry_date, $a_year_later, "today + 12 months must be $a_year_later" );
305
        $retrieved_expiry_date = Koha::Patrons->find( $patron->{borrowernumber} )->dateexpiry;
305
        $retrieved_expiry_date = Koha::Patrons->find( $patron->{borrowernumber} )->dateexpiry;
306
        is( dt_from_string($retrieved_expiry_date), $a_year_later );
306
        is( dt_from_string($retrieved_expiry_date), $a_year_later, "today + 12 months must be $a_year_later" );
307
        $number_of_logs = $schema->resultset('ActionLog')->search( { module => 'MEMBERS', action => 'RENEW', object => $retrieved_patron->borrowernumber } )->count;
307
        $number_of_logs = $schema->resultset('ActionLog')->search( { module => 'MEMBERS', action => 'RENEW', object => $retrieved_patron->borrowernumber } )->count;
308
        is( $number_of_logs, 1, 'Without BorrowerLogs, Koha::Patron->renew_account should not have logged' );
308
        is( $number_of_logs, 1, 'Without BorrowerLogs, Koha::Patron->renew_account should not have logged' );
309
309
310
        t::lib::Mocks::mock_preference( 'BorrowerRenewalPeriodBase', 'combination' );
310
        t::lib::Mocks::mock_preference( 'BorrowerRenewalPeriodBase', 'combination' );
311
        $expiry_date = $retrieved_patron_2->renew_account;
311
        $expiry_date = $retrieved_patron_2->renew_account;
312
        is( $expiry_date, $a_year_later );
312
        is( $expiry_date, $a_year_later, "today + 12 months must be $a_year_later" );
313
        $retrieved_expiry_date = Koha::Patrons->find( $patron_2->{borrowernumber} )->dateexpiry;
313
        $retrieved_expiry_date = Koha::Patrons->find( $patron_2->{borrowernumber} )->dateexpiry;
314
        is( dt_from_string($retrieved_expiry_date), $a_year_later );
314
        is( dt_from_string($retrieved_expiry_date), $a_year_later, "today + 12 months must be $a_year_later" );
315
315
316
        $expiry_date = $retrieved_patron_3->renew_account;
316
        $expiry_date = $retrieved_patron_3->renew_account;
317
        is( $expiry_date, $a_year_later_plus_a_month );
317
        is( $expiry_date, $a_year_later_plus_a_month, "$a_month_later + 12 months must be $a_year_later_plus_a_month" );
318
        $retrieved_expiry_date = Koha::Patrons->find( $patron_3->{borrowernumber} )->dateexpiry;
318
        $retrieved_expiry_date = Koha::Patrons->find( $patron_3->{borrowernumber} )->dateexpiry;
319
        is( dt_from_string($retrieved_expiry_date), $a_year_later_plus_a_month );
319
        is( dt_from_string($retrieved_expiry_date), $a_year_later_plus_a_month, "$a_month_later + 12 months must be $a_year_later_plus_a_month" );
320
320
321
        $retrieved_patron->delete;
321
        $retrieved_patron->delete;
322
        $retrieved_patron_2->delete;
322
        $retrieved_patron_2->delete;
323
- 

Return to bug 17699