|
Lines 17-23
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 88; |
20 |
use Test::More tests => 90; |
| 21 |
|
21 |
|
| 22 |
BEGIN { |
22 |
BEGIN { |
| 23 |
require_ok('C4::Circulation'); |
23 |
require_ok('C4::Circulation'); |
|
Lines 37-43
use C4::Overdues qw(UpdateFine CalcFine);
Link Here
|
| 37 |
use Koha::DateUtils; |
37 |
use Koha::DateUtils; |
| 38 |
use Koha::Database; |
38 |
use Koha::Database; |
| 39 |
|
39 |
|
| 40 |
|
|
|
| 41 |
my $schema = Koha::Database->schema; |
40 |
my $schema = Koha::Database->schema; |
| 42 |
$schema->storage->txn_begin; |
41 |
$schema->storage->txn_begin; |
| 43 |
my $builder = t::lib::TestBuilder->new; |
42 |
my $builder = t::lib::TestBuilder->new; |
|
Lines 553-558
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
| 553 |
'Bug 14101: Cannot renew, renewal is automatic (returned code is auto_renew)' |
552 |
'Bug 14101: Cannot renew, renewal is automatic (returned code is auto_renew)' |
| 554 |
); |
553 |
); |
| 555 |
|
554 |
|
|
|
555 |
subtest "too_late_renewal / no_auto_renewal_after" => sub { |
| 556 |
plan tests => 8; |
| 557 |
my $item_to_auto_renew = $builder->build( |
| 558 |
{ source => 'Item', |
| 559 |
value => { |
| 560 |
biblionumber => $biblionumber, |
| 561 |
homebranch => $branch, |
| 562 |
holdingbranch => $branch, |
| 563 |
} |
| 564 |
} |
| 565 |
); |
| 566 |
|
| 567 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
| 568 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
| 569 |
AddIssue( $renewing_borrower, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
| 570 |
|
| 571 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 7, no_auto_renewal_after = 9'); |
| 572 |
( $renewokay, $error ) = |
| 573 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 574 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 575 |
is( $error, 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' ); |
| 576 |
|
| 577 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 7, no_auto_renewal_after = 10'); |
| 578 |
( $renewokay, $error ) = |
| 579 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 580 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 581 |
is( $error, 'auto_too_late', 'Cannot auto renew, too late - no_auto_renewal_after is inclusive(returned code is auto_too_late)' ); |
| 582 |
|
| 583 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 7, no_auto_renewal_after = 11'); |
| 584 |
( $renewokay, $error ) = |
| 585 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 586 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 587 |
is( $error, 'auto_too_soon', 'Cannot auto renew, too soon - no_auto_renewal_after is defined(returned code is auto_too_soon)' ); |
| 588 |
|
| 589 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 10, no_auto_renewal_after = 11'); |
| 590 |
( $renewokay, $error ) = |
| 591 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 592 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 593 |
is( $error, 'auto_renew', 'Cannot renew, renew is automatic' ); |
| 594 |
}; |
| 595 |
|
| 556 |
# Too many renewals |
596 |
# Too many renewals |
| 557 |
|
597 |
|
| 558 |
# set policy to forbid renewals |
598 |
# set policy to forbid renewals |
| 559 |
- |
|
|