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

(-)a/t/db_dependent/Circulation.t (-12 / +31 lines)
Lines 29-35 use Koha::Database; Link Here
29
29
30
use t::lib::TestBuilder;
30
use t::lib::TestBuilder;
31
31
32
use Test::More tests => 78 ;
32
use Test::More tests => 82;
33
33
34
BEGIN {
34
BEGIN {
35
    use_ok('C4::Circulation');
35
    use_ok('C4::Circulation');
Lines 175-181 $dbh->do( Link Here
175
    '*', '*', '*', 25,
175
    '*', '*', '*', 25,
176
    20, 14, 'days',
176
    20, 14, 'days',
177
    1, 7,
177
    1, 7,
178
    '', 0,
178
    undef, 0,
179
    .10, 1
179
    .10, 1
180
);
180
);
181
181
Lines 470-497 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
470
    AddIssue( $renewing_borrower, $barcode4, undef, undef, undef, undef, { auto_renew => 1 } );
470
    AddIssue( $renewing_borrower, $barcode4, undef, undef, undef, undef, { auto_renew => 1 } );
471
    ( $renewokay, $error ) =
471
    ( $renewokay, $error ) =
472
      CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 );
472
      CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 );
473
    is( $renewokay, 0, 'Cannot renew, renewal is automatic' );
473
    is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' );
474
    is( $error, 'auto_renew',
474
    is( $error, 'auto_too_soon',
475
        'Cannot renew, renewal is automatic (returned code is auto_renew)' );
475
        'Bug 14101: Cannot renew, renewal is automatic and premature, "No renewal before" = undef (returned code is auto_too_soon)' );
476
476
477
    # set policy to require that loans cannot be
477
    # set policy to require that loans cannot be
478
    # renewed until seven days prior to the due date
478
    # renewed until seven days prior to the due date
479
    $dbh->do('UPDATE issuingrules SET norenewalbefore = 7');
479
    $dbh->do('UPDATE issuingrules SET norenewalbefore = 7');
480
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber);
480
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber);
481
    is( $renewokay, 0, 'Cannot renew, renewal is premature');
481
    is( $renewokay, 0, 'Bug 7413: Cannot renew, renewal is premature');
482
    is( $error, 'too_soon', 'Cannot renew, renewal is premature (returned code is too_soon)');
482
    is( $error, 'too_soon', 'Bug 7413: Cannot renew, renewal is premature (returned code is too_soon)');
483
    is(
483
    is(
484
        GetSoonestRenewDate($renewing_borrowernumber, $itemnumber),
484
        GetSoonestRenewDate($renewing_borrowernumber, $itemnumber),
485
        $datedue->clone->add(days => -7),
485
        $datedue->clone->add(days => -7),
486
        'renewals permitted 7 days before due date, as expected',
486
        'Bug 7413: Renewals permitted 7 days before due date, as expected',
487
    );
487
    );
488
488
489
    # Test automatic renewal again
489
    # Test automatic renewal again
490
    ( $renewokay, $error ) =
490
    ( $renewokay, $error ) =
491
      CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 );
491
      CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 );
492
    is( $renewokay, 0, 'Cannot renew, renewal is automatic and premature' );
492
    is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' );
493
    is( $error, 'auto_too_soon',
494
'Bug 14101: Cannot renew, renewal is automatic and premature (returned code is auto_too_soon)'
495
    );
496
497
    # Change policy so that loans can only be renewed exactly on due date (0 days prior to due date)
498
    # and test automatic renewal again
499
    $dbh->do('UPDATE issuingrules SET norenewalbefore = 0');
500
    ( $renewokay, $error ) =
501
      CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 );
502
    is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' );
493
    is( $error, 'auto_too_soon',
503
    is( $error, 'auto_too_soon',
494
'Cannot renew, renewal is automatic and premature (returned code is auto_too_soon)'
504
'Bug 14101: Cannot renew, renewal is automatic and premature, "No renewal before" = 0 (returned code is auto_too_soon)'
505
    );
506
507
    # Change policy so that loans can be renewed 99 days prior to the due date
508
    # and test automatic renewal again
509
    $dbh->do('UPDATE issuingrules SET norenewalbefore = 99');
510
    ( $renewokay, $error ) =
511
      CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 );
512
    is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic' );
513
    is( $error, 'auto_renew',
514
'Bug 14101: Cannot renew, renewal is automatic (returned code is auto_renew)'
495
    );
515
    );
496
516
497
    # Too many renewals
517
    # Too many renewals
Lines 693-699 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
693
        '*', '*', '*', 25,
713
        '*', '*', '*', 25,
694
        20,  14,  'days',
714
        20,  14,  'days',
695
        1,   7,
715
        1,   7,
696
        '',  0,
716
        undef,  0,
697
        .10, 1
717
        .10, 1
698
    );
718
    );
699
    my $biblio = MARC::Record->new();
719
    my $biblio = MARC::Record->new();
700
- 

Return to bug 14101