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 => 78 ; |
30 |
use Test::More tests => 82; |
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 460-487
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
460 |
AddIssue( $renewing_borrower, $barcode4, undef, undef, undef, undef, { auto_renew => 1 } ); |
460 |
AddIssue( $renewing_borrower, $barcode4, undef, undef, undef, undef, { auto_renew => 1 } ); |
461 |
( $renewokay, $error ) = |
461 |
( $renewokay, $error ) = |
462 |
CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 ); |
462 |
CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 ); |
463 |
is( $renewokay, 0, 'Cannot renew, renewal is automatic' ); |
463 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' ); |
464 |
is( $error, 'auto_renew', |
464 |
is( $error, 'auto_too_soon', |
465 |
'Cannot renew, renewal is automatic (returned code is auto_renew)' ); |
465 |
'Bug 14101: Cannot renew, renewal is automatic and premature, "No renewal before" = undef (returned code is auto_too_soon)' ); |
466 |
|
466 |
|
467 |
# set policy to require that loans cannot be |
467 |
# set policy to require that loans cannot be |
468 |
# renewed until seven days prior to the due date |
468 |
# renewed until seven days prior to the due date |
469 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 7'); |
469 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 7'); |
470 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber); |
470 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber); |
471 |
is( $renewokay, 0, 'Cannot renew, renewal is premature'); |
471 |
is( $renewokay, 0, 'Bug 7413: Cannot renew, renewal is premature'); |
472 |
is( $error, 'too_soon', 'Cannot renew, renewal is premature (returned code is too_soon)'); |
472 |
is( $error, 'too_soon', 'Bug 7413: Cannot renew, renewal is premature (returned code is too_soon)'); |
473 |
is( |
473 |
is( |
474 |
GetSoonestRenewDate($renewing_borrowernumber, $itemnumber), |
474 |
GetSoonestRenewDate($renewing_borrowernumber, $itemnumber), |
475 |
$datedue->clone->add(days => -7), |
475 |
$datedue->clone->add(days => -7), |
476 |
'renewals permitted 7 days before due date, as expected', |
476 |
'Bug 7413: Renewals permitted 7 days before due date, as expected', |
477 |
); |
477 |
); |
478 |
|
478 |
|
479 |
# Test automatic renewal again |
479 |
# Test automatic renewal again |
480 |
( $renewokay, $error ) = |
480 |
( $renewokay, $error ) = |
481 |
CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 ); |
481 |
CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 ); |
482 |
is( $renewokay, 0, 'Cannot renew, renewal is automatic and premature' ); |
482 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' ); |
|
|
483 |
is( $error, 'auto_too_soon', |
484 |
'Bug 14101: Cannot renew, renewal is automatic and premature (returned code is auto_too_soon)' |
485 |
); |
486 |
|
487 |
# Change policy so that loans can only be renewed exactly on due date (0 days prior to due date) |
488 |
# and test automatic renewal again |
489 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 0'); |
490 |
( $renewokay, $error ) = |
491 |
CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 ); |
492 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' ); |
483 |
is( $error, 'auto_too_soon', |
493 |
is( $error, 'auto_too_soon', |
484 |
'Cannot renew, renewal is automatic and premature (returned code is auto_too_soon)' |
494 |
'Bug 14101: Cannot renew, renewal is automatic and premature, "No renewal before" = 0 (returned code is auto_too_soon)' |
|
|
495 |
); |
496 |
|
497 |
# Change policy so that loans can be renewed 99 days prior to the due date |
498 |
# and test automatic renewal again |
499 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 99'); |
500 |
( $renewokay, $error ) = |
501 |
CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 ); |
502 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic' ); |
503 |
is( $error, 'auto_renew', |
504 |
'Bug 14101: Cannot renew, renewal is automatic (returned code is auto_renew)' |
485 |
); |
505 |
); |
486 |
|
506 |
|
487 |
# Too many renewals |
507 |
# Too many renewals |
Lines 683-689
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
683 |
'*', '*', '*', 25, |
703 |
'*', '*', '*', 25, |
684 |
20, 14, 'days', |
704 |
20, 14, 'days', |
685 |
1, 7, |
705 |
1, 7, |
686 |
'', 0, |
706 |
undef, 0, |
687 |
.10, 1 |
707 |
.10, 1 |
688 |
); |
708 |
); |
689 |
my $biblio = MARC::Record->new(); |
709 |
my $biblio = MARC::Record->new(); |
690 |
- |
|
|