Lines 30-36
use Koha::Database;
Link Here
|
30 |
|
30 |
|
31 |
use t::lib::TestBuilder; |
31 |
use t::lib::TestBuilder; |
32 |
|
32 |
|
33 |
use Test::More tests => 83; |
33 |
use Test::More tests => 84; |
34 |
|
34 |
|
35 |
BEGIN { |
35 |
BEGIN { |
36 |
use_ok('C4::Circulation'); |
36 |
use_ok('C4::Circulation'); |
Lines 573-578
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
573 |
is( $error, 'auto_renew', 'Cannot renew, renew is automatic' ); |
573 |
is( $error, 'auto_renew', 'Cannot renew, renew is automatic' ); |
574 |
}; |
574 |
}; |
575 |
|
575 |
|
|
|
576 |
subtest "GetLatestAutoRenewDate" => sub { |
577 |
plan tests => 3; |
578 |
my $item_to_auto_renew = $builder->build( |
579 |
{ source => 'Item', |
580 |
value => { |
581 |
biblionumber => $biblionumber, |
582 |
homebranch => $branch, |
583 |
holdingbranch => $branch, |
584 |
} |
585 |
} |
586 |
); |
587 |
|
588 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
589 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
590 |
AddIssue( $renewing_borrower, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
591 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 7, no_auto_renewal_after = ""'); |
592 |
my $latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
593 |
is( $latest_auto_renew_date, undef, 'GetLatestAutoRenewDate should return undef if no_auto_renewal_after is not defined' ); |
594 |
my $five_days_before = dt_from_string->add( days => -5 ); |
595 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 10, no_auto_renewal_after = 5'); |
596 |
$latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
597 |
is( $latest_auto_renew_date->truncate( to => 'minute' ), |
598 |
$five_days_before->truncate( to => 'minute' ), |
599 |
'GetLatestAutoRenewDate should return -5 days if no_auto_renewal_after = 5 and date_due is 10 days before' |
600 |
); |
601 |
my $five_days_ahead = dt_from_string->add( days => 5 ); |
602 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 10, no_auto_renewal_after = 15'); |
603 |
$latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
604 |
is( $latest_auto_renew_date->truncate( to => 'minute' ), |
605 |
$five_days_ahead->truncate( to => 'minute' ), |
606 |
'GetLatestAutoRenewDate should return +5 days if no_auto_renewal_after = 15 and date_due is 10 days before' |
607 |
); |
608 |
}; |
609 |
|
576 |
# Too many renewals |
610 |
# Too many renewals |
577 |
|
611 |
|
578 |
# set policy to forbid renewals |
612 |
# set policy to forbid renewals |
579 |
- |
|
|