|
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 => 83; |
32 |
use Test::More tests => 84; |
| 33 |
|
33 |
|
| 34 |
BEGIN { |
34 |
BEGIN { |
| 35 |
use_ok('C4::Circulation'); |
35 |
use_ok('C4::Circulation'); |
|
Lines 555-560
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
| 555 |
is( $error, 'auto_renew', 'Cannot renew, renew is automatic' ); |
555 |
is( $error, 'auto_renew', 'Cannot renew, renew is automatic' ); |
| 556 |
}; |
556 |
}; |
| 557 |
|
557 |
|
|
|
558 |
subtest "GetLatestAutoRenewDate" => sub { |
| 559 |
plan tests => 3; |
| 560 |
my $item_to_auto_renew = $builder->build( |
| 561 |
{ source => 'Item', |
| 562 |
value => { |
| 563 |
biblionumber => $biblionumber, |
| 564 |
homebranch => $branch, |
| 565 |
holdingbranch => $branch, |
| 566 |
} |
| 567 |
} |
| 568 |
); |
| 569 |
|
| 570 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
| 571 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
| 572 |
AddIssue( $renewing_borrower, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
| 573 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 7, no_auto_renewal_after = ""'); |
| 574 |
my $latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 575 |
is( $latest_auto_renew_date, undef, 'GetLatestAutoRenewDate should return undef if no_auto_renewal_after is not defined' ); |
| 576 |
my $five_days_before = dt_from_string->add( days => -5 ); |
| 577 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 10, no_auto_renewal_after = 5'); |
| 578 |
$latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 579 |
is( $latest_auto_renew_date->truncate( to => 'minute' ), |
| 580 |
$five_days_before->truncate( to => 'minute' ), |
| 581 |
'GetLatestAutoRenewDate should return -5 days if no_auto_renewal_after = 5 and date_due is 10 days before' |
| 582 |
); |
| 583 |
my $five_days_ahead = dt_from_string->add( days => 5 ); |
| 584 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 10, no_auto_renewal_after = 15'); |
| 585 |
$latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 586 |
is( $latest_auto_renew_date->truncate( to => 'minute' ), |
| 587 |
$five_days_ahead->truncate( to => 'minute' ), |
| 588 |
'GetLatestAutoRenewDate should return +5 days if no_auto_renewal_after = 15 and date_due is 10 days before' |
| 589 |
); |
| 590 |
}; |
| 591 |
|
| 558 |
# Too many renewals |
592 |
# Too many renewals |
| 559 |
|
593 |
|
| 560 |
# set policy to forbid renewals |
594 |
# set policy to forbid renewals |
| 561 |
- |
|
|