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 => 82; |
32 |
use Test::More tests => 83; |
33 |
|
33 |
|
34 |
BEGIN { |
34 |
BEGIN { |
35 |
use_ok('C4::Circulation'); |
35 |
use_ok('C4::Circulation'); |
Lines 514-519
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
514 |
'Bug 14101: Cannot renew, renewal is automatic (returned code is auto_renew)' |
514 |
'Bug 14101: Cannot renew, renewal is automatic (returned code is auto_renew)' |
515 |
); |
515 |
); |
516 |
|
516 |
|
|
|
517 |
subtest "too_late_renewal / no_auto_renewal_after" => sub { |
518 |
plan tests => 8; |
519 |
my $item_to_auto_renew = $builder->build( |
520 |
{ source => 'Item', |
521 |
value => { |
522 |
biblionumber => $biblionumber, |
523 |
homebranch => $branch, |
524 |
holdingbranch => $branch, |
525 |
} |
526 |
} |
527 |
); |
528 |
|
529 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
530 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
531 |
AddIssue( $renewing_borrower, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
532 |
|
533 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 7, no_auto_renewal_after = 9'); |
534 |
( $renewokay, $error ) = |
535 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
536 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
537 |
is( $error, 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' ); |
538 |
|
539 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 7, no_auto_renewal_after = 10'); |
540 |
( $renewokay, $error ) = |
541 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
542 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
543 |
is( $error, 'auto_too_late', 'Cannot auto renew, too late - no_auto_renewal_after is inclusive(returned code is auto_too_late)' ); |
544 |
|
545 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 7, no_auto_renewal_after = 11'); |
546 |
( $renewokay, $error ) = |
547 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
548 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
549 |
is( $error, 'auto_too_soon', 'Cannot auto renew, too soon - no_auto_renewal_after is defined(returned code is auto_too_late)' ); |
550 |
|
551 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 10, no_auto_renewal_after = 11'); |
552 |
( $renewokay, $error ) = |
553 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
554 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
555 |
is( $error, 'auto_renew', 'Cannot renew, renew is automatic' ); |
556 |
}; |
557 |
|
517 |
# Too many renewals |
558 |
# Too many renewals |
518 |
|
559 |
|
519 |
# set policy to forbid renewals |
560 |
# set policy to forbid renewals |
520 |
- |
|
|