Lines 418-424
subtest "GetIssuingCharges tests" => sub {
Link Here
|
418 |
|
418 |
|
419 |
my ( $reused_itemnumber_1, $reused_itemnumber_2 ); |
419 |
my ( $reused_itemnumber_1, $reused_itemnumber_2 ); |
420 |
subtest "CanBookBeRenewed tests" => sub { |
420 |
subtest "CanBookBeRenewed tests" => sub { |
421 |
plan tests => 93; |
421 |
plan tests => 100; |
422 |
|
422 |
|
423 |
C4::Context->set_preference('ItemsDeniedRenewal',''); |
423 |
C4::Context->set_preference('ItemsDeniedRenewal',''); |
424 |
# Generate test biblio |
424 |
# Generate test biblio |
Lines 794-804
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
794 |
); |
794 |
); |
795 |
|
795 |
|
796 |
$issue = AddIssue( $renewing_borrower, $item_4->barcode, undef, undef, undef, undef, { auto_renew => 1 } ); |
796 |
$issue = AddIssue( $renewing_borrower, $item_4->barcode, undef, undef, undef, undef, { auto_renew => 1 } ); |
797 |
( $renewokay, $error ) = |
797 |
my $info; |
|
|
798 |
( $renewokay, $error, $info ) = |
798 |
CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
799 |
CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
799 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' ); |
800 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' ); |
800 |
is( $error, 'auto_too_soon', |
801 |
is( $error, 'auto_too_soon', |
801 |
'Bug 14101: Cannot renew, renewal is automatic and premature, "No renewal before" = undef (returned code is auto_too_soon)' ); |
802 |
'Bug 14101: Cannot renew, renewal is automatic and premature, "No renewal before" = undef (returned code is auto_too_soon)' ); |
|
|
803 |
is( $info, $issue->date_due, "Due date is returned as earliest renewal date when error is 'auto_too_soon'" ); |
802 |
AddReserve( |
804 |
AddReserve( |
803 |
{ |
805 |
{ |
804 |
branchcode => $branch, |
806 |
branchcode => $branch, |
Lines 817-825
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
817 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
819 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
818 |
is( $renewokay, 0, 'Still should not be able to renew' ); |
820 |
is( $renewokay, 0, 'Still should not be able to renew' ); |
819 |
is( $error, 'on_reserve', 'returned code is on_reserve, reserve checked when not checking for cron' ); |
821 |
is( $error, 'on_reserve', 'returned code is on_reserve, reserve checked when not checking for cron' ); |
820 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber, undef, 1 ); |
822 |
( $renewokay, $error, $info ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber, undef, 1 ); |
821 |
is( $renewokay, 0, 'Still should not be able to renew' ); |
823 |
is( $renewokay, 0, 'Still should not be able to renew' ); |
822 |
is( $error, 'auto_too_soon', 'returned code is auto_too_soon, reserve not checked when checking for cron' ); |
824 |
is( $error, 'auto_too_soon', 'returned code is auto_too_soon, reserve not checked when checking for cron' ); |
|
|
825 |
is( $info, $issue->date_due, "Due date is returned as earliest renewal date when error is 'auto_too_soon'" ); |
823 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber, 1 ); |
826 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber, 1 ); |
824 |
is( $renewokay, 0, 'Still should not be able to renew' ); |
827 |
is( $renewokay, 0, 'Still should not be able to renew' ); |
825 |
is( $error, 'on_reserve', 'returned code is on_reserve, auto_too_soon limit is overridden' ); |
828 |
is( $error, 'on_reserve', 'returned code is on_reserve, auto_too_soon limit is overridden' ); |
Lines 852-890
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
852 |
} |
855 |
} |
853 |
); |
856 |
); |
854 |
|
857 |
|
855 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber); |
858 |
( $renewokay, $error, $info ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber); |
856 |
is( $renewokay, 0, 'Bug 7413: Cannot renew, renewal is premature'); |
859 |
is( $renewokay, 0, 'Bug 7413: Cannot renew, renewal is premature'); |
857 |
is( $error, 'too_soon', 'Bug 7413: Cannot renew, renewal is premature (returned code is too_soon)'); |
860 |
is( $error, 'too_soon', 'Bug 7413: Cannot renew, renewal is premature (returned code is too_soon)'); |
|
|
861 |
is( $info, dt_from_string($issue->date_due)->subtract( days => 7 ), "Soonest renew date returned when error is 'too_soon'"); |
858 |
|
862 |
|
859 |
# Bug 14101 |
863 |
# Bug 14101 |
860 |
# Test premature automatic renewal |
864 |
# Test premature automatic renewal |
861 |
( $renewokay, $error ) = |
865 |
( $renewokay, $error, $info ) = |
862 |
CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
866 |
CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
863 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' ); |
867 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' ); |
864 |
is( $error, 'auto_too_soon', |
868 |
is( $error, 'auto_too_soon', |
865 |
'Bug 14101: Cannot renew, renewal is automatic and premature (returned code is auto_too_soon)' |
869 |
'Bug 14101: Cannot renew, renewal is automatic and premature (returned code is auto_too_soon)' |
866 |
); |
870 |
); |
|
|
871 |
is( $info, dt_from_string($issue->date_due)->subtract( days => 7 ), "Soonest renew date returned when error is 'auto_too_soon'"); |
867 |
|
872 |
|
868 |
$renewing_borrower_obj->autorenew_checkouts(0)->store; |
873 |
$renewing_borrower_obj->autorenew_checkouts(0)->store; |
869 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
874 |
( $renewokay, $error, $info ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
870 |
is( $renewokay, 0, 'No renewal before is 7, patron opted out of auto_renewal still cannot renew early' ); |
875 |
is( $renewokay, 0, 'No renewal before is 7, patron opted out of auto_renewal still cannot renew early' ); |
871 |
is( $error, 'too_soon', 'Error is too_soon, no auto' ); |
876 |
is( $error, 'too_soon', 'Error is too_soon, no auto' ); |
|
|
877 |
is( $info, dt_from_string($issue->date_due)->subtract( days => 7 ), "Soonest renew date returned when error is 'too_soon'"); |
872 |
$renewing_borrower_obj->autorenew_checkouts(1)->store; |
878 |
$renewing_borrower_obj->autorenew_checkouts(1)->store; |
873 |
|
879 |
|
874 |
# Change policy so that loans can only be renewed exactly on due date (0 days prior to due date) |
880 |
# Change policy so that loans can only be renewed exactly on due date (0 days prior to due date) |
875 |
# and test automatic renewal again |
881 |
# and test automatic renewal again |
876 |
$dbh->do(q{UPDATE circulation_rules SET rule_value = '0' WHERE rule_name = 'norenewalbefore'}); |
882 |
$dbh->do(q{UPDATE circulation_rules SET rule_value = '0' WHERE rule_name = 'norenewalbefore'}); |
877 |
( $renewokay, $error ) = |
883 |
( $renewokay, $error, $info ) = |
878 |
CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
884 |
CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
879 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' ); |
885 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' ); |
880 |
is( $error, 'auto_too_soon', |
886 |
is( $error, 'auto_too_soon', |
881 |
'Bug 14101: Cannot renew, renewal is automatic and premature, "No renewal before" = 0 (returned code is auto_too_soon)' |
887 |
'Bug 14101: Cannot renew, renewal is automatic and premature, "No renewal before" = 0 (returned code is auto_too_soon)' |
882 |
); |
888 |
); |
|
|
889 |
is( $info, dt_from_string($issue->date_due), "Soonest renew date returned when error is 'auto_too_soon'"); |
883 |
|
890 |
|
884 |
$renewing_borrower_obj->autorenew_checkouts(0)->store; |
891 |
$renewing_borrower_obj->autorenew_checkouts(0)->store; |
885 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
892 |
( $renewokay, $error, $info ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
886 |
is( $renewokay, 0, 'No renewal before is 0, patron opted out of auto_renewal still cannot renew early' ); |
893 |
is( $renewokay, 0, 'No renewal before is 0, patron opted out of auto_renewal still cannot renew early' ); |
887 |
is( $error, 'too_soon', 'Error is too_soon, no auto' ); |
894 |
is( $error, 'too_soon', 'Error is too_soon, no auto' ); |
|
|
895 |
is( $info, dt_from_string($issue->date_due), "Soonest renew date returned when error is 'auto_too_soon'"); |
888 |
$renewing_borrower_obj->autorenew_checkouts(1)->store; |
896 |
$renewing_borrower_obj->autorenew_checkouts(1)->store; |
889 |
|
897 |
|
890 |
# Change policy so that loans can be renewed 99 days prior to the due date |
898 |
# Change policy so that loans can be renewed 99 days prior to the due date |
891 |
- |
|
|