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 => 87; |
32 |
use Test::More tests => 88; |
33 |
|
33 |
|
34 |
BEGIN { |
34 |
BEGIN { |
35 |
use_ok('C4::Circulation'); |
35 |
use_ok('C4::Circulation'); |
Lines 591-596
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
591 |
is( $error, 'auto_renew', 'Cannot renew, renew is automatic' ); |
591 |
is( $error, 'auto_renew', 'Cannot renew, renew is automatic' ); |
592 |
}; |
592 |
}; |
593 |
|
593 |
|
|
|
594 |
subtest "GetLatestAutoRenewDate" => sub { |
595 |
plan tests => 3; |
596 |
my $item_to_auto_renew = $builder->build( |
597 |
{ source => 'Item', |
598 |
value => { |
599 |
biblionumber => $biblionumber, |
600 |
homebranch => $branch, |
601 |
holdingbranch => $branch, |
602 |
} |
603 |
} |
604 |
); |
605 |
|
606 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
607 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
608 |
AddIssue( $renewing_borrower, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
609 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 7, no_auto_renewal_after = ""'); |
610 |
my $latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
611 |
is( $latest_auto_renew_date, undef, 'GetLatestAutoRenewDate should return undef if no_auto_renewal_after is not defined' ); |
612 |
my $five_days_before = dt_from_string->add( days => -5 ); |
613 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 10, no_auto_renewal_after = 5'); |
614 |
$latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
615 |
is( $latest_auto_renew_date->truncate( to => 'minute' ), |
616 |
$five_days_before->truncate( to => 'minute' ), |
617 |
'GetLatestAutoRenewDate should return -5 days if no_auto_renewal_after = 5 and date_due is 10 days before' |
618 |
); |
619 |
my $five_days_ahead = dt_from_string->add( days => 5 ); |
620 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 10, no_auto_renewal_after = 15'); |
621 |
$latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
622 |
is( $latest_auto_renew_date->truncate( to => 'minute' ), |
623 |
$five_days_ahead->truncate( to => 'minute' ), |
624 |
'GetLatestAutoRenewDate should return +5 days if no_auto_renewal_after = 15 and date_due is 10 days before' |
625 |
); |
626 |
}; |
627 |
|
594 |
# Too many renewals |
628 |
# Too many renewals |
595 |
|
629 |
|
596 |
# set policy to forbid renewals |
630 |
# set policy to forbid renewals |
597 |
- |
|
|