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

(-)a/t/db_dependent/Circulation.t (-12 / +31 lines)
Lines 27-33 use C4::Overdues qw(UpdateFine); Link Here
27
use Koha::DateUtils;
27
use Koha::DateUtils;
28
use Koha::Database;
28
use Koha::Database;
29
29
30
use Test::More tests => 69;
30
use Test::More tests => 73;
31
31
32
BEGIN {
32
BEGIN {
33
    use_ok('C4::Circulation');
33
    use_ok('C4::Circulation');
Lines 165-171 $dbh->do( Link Here
165
    '*', '*', '*', 25,
165
    '*', '*', '*', 25,
166
    20, 14, 'days',
166
    20, 14, 'days',
167
    1, 7,
167
    1, 7,
168
    '', 0,
168
    undef, 0,
169
    .10, 1
169
    .10, 1
170
);
170
);
171
171
Lines 391-418 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
391
    AddIssue( $renewing_borrower, $barcode4, undef, undef, undef, undef, { auto_renew => 1 } );
391
    AddIssue( $renewing_borrower, $barcode4, undef, undef, undef, undef, { auto_renew => 1 } );
392
    ( $renewokay, $error ) =
392
    ( $renewokay, $error ) =
393
      CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 );
393
      CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 );
394
    is( $renewokay, 0, 'Cannot renew, renewal is automatic' );
394
    is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' );
395
    is( $error, 'auto_renew',
395
    is( $error, 'auto_too_soon',
396
        'Cannot renew, renewal is automatic (returned code is auto_renew)' );
396
        'Bug 14101: Cannot renew, renewal is automatic and premature, "No renewal before" = undef (returned code is auto_too_soon)' );
397
397
398
    # set policy to require that loans cannot be
398
    # set policy to require that loans cannot be
399
    # renewed until seven days prior to the due date
399
    # renewed until seven days prior to the due date
400
    $dbh->do('UPDATE issuingrules SET norenewalbefore = 7');
400
    $dbh->do('UPDATE issuingrules SET norenewalbefore = 7');
401
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber);
401
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber);
402
    is( $renewokay, 0, 'Cannot renew, renewal is premature');
402
    is( $renewokay, 0, 'Bug 7413: Cannot renew, renewal is premature');
403
    is( $error, 'too_soon', 'Cannot renew, renewal is premature (returned code is too_soon)');
403
    is( $error, 'too_soon', 'Bug 7413: Cannot renew, renewal is premature (returned code is too_soon)');
404
    is(
404
    is(
405
        GetSoonestRenewDate($renewing_borrowernumber, $itemnumber),
405
        GetSoonestRenewDate($renewing_borrowernumber, $itemnumber),
406
        $datedue->clone->add(days => -7),
406
        $datedue->clone->add(days => -7),
407
        'renewals permitted 7 days before due date, as expected',
407
        'Bug 7413: Renewals permitted 7 days before due date, as expected',
408
    );
408
    );
409
409
410
    # Test automatic renewal again
410
    # Test automatic renewal again
411
    ( $renewokay, $error ) =
411
    ( $renewokay, $error ) =
412
      CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 );
412
      CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 );
413
    is( $renewokay, 0, 'Cannot renew, renewal is automatic and premature' );
413
    is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' );
414
    is( $error, 'auto_too_soon',
415
'Bug 14101: Cannot renew, renewal is automatic and premature (returned code is auto_too_soon)'
416
    );
417
418
    # Change policy so that loans can only be renewed exactly on due date (0 days prior to due date)
419
    # and test automatic renewal again
420
    $dbh->do('UPDATE issuingrules SET norenewalbefore = 0');
421
    ( $renewokay, $error ) =
422
      CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 );
423
    is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' );
414
    is( $error, 'auto_too_soon',
424
    is( $error, 'auto_too_soon',
415
'Cannot renew, renewal is automatic and premature (returned code is auto_too_soon)'
425
'Bug 14101: Cannot renew, renewal is automatic and premature, "No renewal before" = 0 (returned code is auto_too_soon)'
426
    );
427
428
    # Change policy so that loans can be renewed 99 days prior to the due date
429
    # and test automatic renewal again
430
    $dbh->do('UPDATE issuingrules SET norenewalbefore = 99');
431
    ( $renewokay, $error ) =
432
      CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 );
433
    is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic' );
434
    is( $error, 'auto_renew',
435
'Bug 14101: Cannot renew, renewal is automatic (returned code is auto_renew)'
416
    );
436
    );
417
437
418
    # Too many renewals
438
    # Too many renewals
Lines 606-612 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
606
        '*', '*', '*', 25,
626
        '*', '*', '*', 25,
607
        20,  14,  'days',
627
        20,  14,  'days',
608
        1,   7,
628
        1,   7,
609
        '',  0,
629
        undef,  0,
610
        .10, 1
630
        .10, 1
611
    );
631
    );
612
    my $biblio = MARC::Record->new();
632
    my $biblio = MARC::Record->new();
613
- 

Return to bug 14101