Lines 800-806
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
800 |
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' ); |
801 |
is( $error, 'auto_too_soon', |
801 |
is( $error, 'auto_too_soon', |
802 |
'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'" ); |
803 |
is( $info->{soonest_renew_date} , $issue->date_due, "Due date is returned as earliest renewal date when error is 'auto_too_soon'" ); |
804 |
AddReserve( |
804 |
AddReserve( |
805 |
{ |
805 |
{ |
806 |
branchcode => $branch, |
806 |
branchcode => $branch, |
Lines 822-828
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
822 |
( $renewokay, $error, $info ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber, undef, 1 ); |
822 |
( $renewokay, $error, $info ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber, undef, 1 ); |
823 |
is( $renewokay, 0, 'Still should not be able to renew' ); |
823 |
is( $renewokay, 0, 'Still should not be able to renew' ); |
824 |
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'" ); |
825 |
is( $info->{soonest_renew_date}, $issue->date_due, "Due date is returned as earliest renewal date when error is 'auto_too_soon'" ); |
826 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber, 1 ); |
826 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber, 1 ); |
827 |
is( $renewokay, 0, 'Still should not be able to renew' ); |
827 |
is( $renewokay, 0, 'Still should not be able to renew' ); |
828 |
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 858-864
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
858 |
( $renewokay, $error, $info ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber); |
858 |
( $renewokay, $error, $info ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber); |
859 |
is( $renewokay, 0, 'Bug 7413: Cannot renew, renewal is premature'); |
859 |
is( $renewokay, 0, 'Bug 7413: Cannot renew, renewal is premature'); |
860 |
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'"); |
861 |
is( $info->{soonest_renew_date}, dt_from_string($issue->date_due)->subtract( days => 7 ), "Soonest renew date returned when error is 'too_soon'"); |
862 |
|
862 |
|
863 |
# Bug 14101 |
863 |
# Bug 14101 |
864 |
# Test premature automatic renewal |
864 |
# Test premature automatic renewal |
Lines 868-880
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
868 |
is( $error, 'auto_too_soon', |
868 |
is( $error, 'auto_too_soon', |
869 |
'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)' |
870 |
); |
870 |
); |
871 |
is( $info, dt_from_string($issue->date_due)->subtract( days => 7 ), "Soonest renew date returned when error is 'auto_too_soon'"); |
871 |
is( $info->{soonest_renew_date}, dt_from_string($issue->date_due)->subtract( days => 7 ), "Soonest renew date returned when error is 'auto_too_soon'"); |
872 |
|
872 |
|
873 |
$renewing_borrower_obj->autorenew_checkouts(0)->store; |
873 |
$renewing_borrower_obj->autorenew_checkouts(0)->store; |
874 |
( $renewokay, $error, $info ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
874 |
( $renewokay, $error, $info ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
875 |
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' ); |
876 |
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'"); |
877 |
is( $info->{soonest_renew_date}, dt_from_string($issue->date_due)->subtract( days => 7 ), "Soonest renew date returned when error is 'too_soon'"); |
878 |
$renewing_borrower_obj->autorenew_checkouts(1)->store; |
878 |
$renewing_borrower_obj->autorenew_checkouts(1)->store; |
879 |
|
879 |
|
880 |
# 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) |
Lines 886-898
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
886 |
is( $error, 'auto_too_soon', |
886 |
is( $error, 'auto_too_soon', |
887 |
'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)' |
888 |
); |
888 |
); |
889 |
is( $info, dt_from_string($issue->date_due), "Soonest renew date returned when error is 'auto_too_soon'"); |
889 |
is( $info->{soonest_renew_date}, dt_from_string($issue->date_due), "Soonest renew date returned when error is 'auto_too_soon'"); |
890 |
|
890 |
|
891 |
$renewing_borrower_obj->autorenew_checkouts(0)->store; |
891 |
$renewing_borrower_obj->autorenew_checkouts(0)->store; |
892 |
( $renewokay, $error, $info ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
892 |
( $renewokay, $error, $info ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
893 |
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' ); |
894 |
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'"); |
895 |
is( $info->{soonest_renew_date}, dt_from_string($issue->date_due), "Soonest renew date returned when error is 'auto_too_soon'"); |
896 |
$renewing_borrower_obj->autorenew_checkouts(1)->store; |
896 |
$renewing_borrower_obj->autorenew_checkouts(1)->store; |
897 |
|
897 |
|
898 |
# 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 |
899 |
- |
|
|