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 => 88; |
32 |
use Test::More tests => 89; |
33 |
|
33 |
|
34 |
BEGIN { |
34 |
BEGIN { |
35 |
use_ok('C4::Circulation'); |
35 |
use_ok('C4::Circulation'); |
Lines 550-555
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
550 |
'Bug 14101: Cannot renew, renewal is automatic (returned code is auto_renew)' |
550 |
'Bug 14101: Cannot renew, renewal is automatic (returned code is auto_renew)' |
551 |
); |
551 |
); |
552 |
|
552 |
|
|
|
553 |
subtest "too_late_renewal / no_auto_renewal_after" => sub { |
554 |
plan tests => 8; |
555 |
my $item_to_auto_renew = $builder->build( |
556 |
{ source => 'Item', |
557 |
value => { |
558 |
biblionumber => $biblionumber, |
559 |
homebranch => $branch, |
560 |
holdingbranch => $branch, |
561 |
} |
562 |
} |
563 |
); |
564 |
|
565 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
566 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
567 |
AddIssue( $renewing_borrower, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
568 |
|
569 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 7, no_auto_renewal_after = 9'); |
570 |
( $renewokay, $error ) = |
571 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
572 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
573 |
is( $error, 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' ); |
574 |
|
575 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 7, no_auto_renewal_after = 10'); |
576 |
( $renewokay, $error ) = |
577 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
578 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
579 |
is( $error, 'auto_too_late', 'Cannot auto renew, too late - no_auto_renewal_after is inclusive(returned code is auto_too_late)' ); |
580 |
|
581 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 7, no_auto_renewal_after = 11'); |
582 |
( $renewokay, $error ) = |
583 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
584 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
585 |
is( $error, 'auto_too_soon', 'Cannot auto renew, too soon - no_auto_renewal_after is defined(returned code is auto_too_soon)' ); |
586 |
|
587 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 10, no_auto_renewal_after = 11'); |
588 |
( $renewokay, $error ) = |
589 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
590 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
591 |
is( $error, 'auto_renew', 'Cannot renew, renew is automatic' ); |
592 |
}; |
593 |
|
553 |
# Too many renewals |
594 |
# Too many renewals |
554 |
|
595 |
|
555 |
# set policy to forbid renewals |
596 |
# set policy to forbid renewals |
556 |
- |
|
|