Lines 452-462
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
452 |
|
452 |
|
453 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber); |
453 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber); |
454 |
is( $renewokay, 0, '(Bug 10663) Cannot renew, reserved'); |
454 |
is( $renewokay, 0, '(Bug 10663) Cannot renew, reserved'); |
455 |
is( $error, 'on_reserve', '(Bug 10663) Cannot renew, reserved (returned error is on_reserve)'); |
455 |
is( $error->[0], 'on_reserve', '(Bug 10663) Cannot renew, reserved (returned error is on_reserve)'); |
456 |
|
456 |
|
457 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_2->itemnumber); |
457 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_2->itemnumber); |
458 |
is( $renewokay, 0, '(Bug 10663) Cannot renew, reserved'); |
458 |
is( $renewokay, 0, '(Bug 10663) Cannot renew, reserved'); |
459 |
is( $error, 'on_reserve', '(Bug 10663) Cannot renew, reserved (returned error is on_reserve)'); |
459 |
is( $error->[0], 'on_reserve', '(Bug 10663) Cannot renew, reserved (returned error is on_reserve)'); |
460 |
|
460 |
|
461 |
my $reserveid = Koha::Holds->search({ biblionumber => $biblio->biblionumber, borrowernumber => $reserving_borrowernumber })->next->reserve_id; |
461 |
my $reserveid = Koha::Holds->search({ biblionumber => $biblio->biblionumber, borrowernumber => $reserving_borrowernumber })->next->reserve_id; |
462 |
my $reserving_borrower = Koha::Patrons->find( $reserving_borrowernumber )->unblessed; |
462 |
my $reserving_borrower = Koha::Patrons->find( $reserving_borrowernumber )->unblessed; |
Lines 485-491
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
485 |
|
485 |
|
486 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber, 1); |
486 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber, 1); |
487 |
is( $renewokay, 0, '(Bug 10663) Cannot renew, item reserved'); |
487 |
is( $renewokay, 0, '(Bug 10663) Cannot renew, item reserved'); |
488 |
is( $error, 'on_reserve', '(Bug 10663) Cannot renew, item reserved (returned error is on_reserve)'); |
488 |
is( $error->[0], 'on_reserve', '(Bug 10663) Cannot renew, item reserved (returned error is on_reserve)'); |
489 |
|
489 |
|
490 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_2->itemnumber, 1); |
490 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_2->itemnumber, 1); |
491 |
is( $renewokay, 1, 'Can renew item 2, item-level hold is on item 1'); |
491 |
is( $renewokay, 1, 'Can renew item 2, item-level hold is on item 1'); |
Lines 629-635
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
629 |
( $renewokay, $error ) = |
629 |
( $renewokay, $error ) = |
630 |
CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
630 |
CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
631 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' ); |
631 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' ); |
632 |
is( $error, 'auto_too_soon', |
632 |
is( $error->[0], 'auto_too_soon', |
633 |
'Bug 14101: Cannot renew, renewal is automatic and premature, "No renewal before" = undef (returned code is auto_too_soon)' ); |
633 |
'Bug 14101: Cannot renew, renewal is automatic and premature, "No renewal before" = undef (returned code is auto_too_soon)' ); |
634 |
AddReserve( |
634 |
AddReserve( |
635 |
{ |
635 |
{ |
Lines 648-661
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
648 |
); |
648 |
); |
649 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
649 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
650 |
is( $renewokay, 0, 'Still should not be able to renew' ); |
650 |
is( $renewokay, 0, 'Still should not be able to renew' ); |
651 |
is( $error, 'auto_too_soon', 'returned code is auto_too_soon, reserve not checked' ); |
651 |
is( $error->[0], 'auto_too_soon', 'returned code is auto_too_soon, reserve not checked' ); |
652 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber, 1 ); |
652 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber, 1 ); |
653 |
is( $renewokay, 0, 'Still should not be able to renew' ); |
653 |
is( $renewokay, 0, 'Still should not be able to renew' ); |
654 |
is( $error, 'on_reserve', 'returned code is on_reserve, auto_too_soon limit is overridden' ); |
654 |
is( $error->[0], 'on_reserve', 'returned code is on_reserve, auto_too_soon limit is overridden' ); |
655 |
$dbh->do('UPDATE circulation_rules SET rule_value = 0 where rule_name = "norenewalbefore"'); |
655 |
$dbh->do('UPDATE circulation_rules SET rule_value = 0 where rule_name = "norenewalbefore"'); |
656 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber, 1 ); |
656 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber, 1 ); |
657 |
is( $renewokay, 0, 'Still should not be able to renew' ); |
657 |
is( $renewokay, 0, 'Still should not be able to renew' ); |
658 |
is( $error, 'on_reserve', 'returned code is on_reserve, auto_renew only happens if not on reserve' ); |
658 |
is( $error->[0], 'on_reserve', 'returned code is on_reserve, auto_renew only happens if not on reserve' ); |
659 |
ModReserveCancelAll($item_4->itemnumber, $reserving_borrowernumber); |
659 |
ModReserveCancelAll($item_4->itemnumber, $reserving_borrowernumber); |
660 |
|
660 |
|
661 |
|
661 |
|
Lines 680-686
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
680 |
|
680 |
|
681 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber); |
681 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber); |
682 |
is( $renewokay, 0, 'Bug 7413: Cannot renew, renewal is premature'); |
682 |
is( $renewokay, 0, 'Bug 7413: Cannot renew, renewal is premature'); |
683 |
is( $error, 'too_soon', 'Bug 7413: Cannot renew, renewal is premature (returned code is too_soon)'); |
683 |
is( $error->[0], 'too_soon', 'Bug 7413: Cannot renew, renewal is premature (returned code is too_soon)'); |
684 |
|
684 |
|
685 |
# Bug 14395 |
685 |
# Bug 14395 |
686 |
# Test 'exact time' setting for syspref NoRenewalBeforePrecision |
686 |
# Test 'exact time' setting for syspref NoRenewalBeforePrecision |
Lines 705-718
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
705 |
( $renewokay, $error ) = |
705 |
( $renewokay, $error ) = |
706 |
CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
706 |
CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
707 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' ); |
707 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' ); |
708 |
is( $error, 'auto_too_soon', |
708 |
is( $error->[0], 'auto_too_soon', |
709 |
'Bug 14101: Cannot renew, renewal is automatic and premature (returned code is auto_too_soon)' |
709 |
'Bug 14101: Cannot renew, renewal is automatic and premature (returned code is auto_too_soon)' |
710 |
); |
710 |
); |
711 |
|
711 |
|
712 |
$renewing_borrower_obj->autorenew_checkouts(0)->store; |
712 |
$renewing_borrower_obj->autorenew_checkouts(0)->store; |
713 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
713 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
714 |
is( $renewokay, 0, 'No renewal before is 7, patron opted out of auto_renewal still cannot renew early' ); |
714 |
is( $renewokay, 0, 'No renewal before is 7, patron opted out of auto_renewal still cannot renew early' ); |
715 |
is( $error, 'too_soon', 'Error is too_soon, no auto' ); |
715 |
is( $error->[0], 'too_soon', 'Error is too_soon, no auto' ); |
716 |
$renewing_borrower_obj->autorenew_checkouts(1)->store; |
716 |
$renewing_borrower_obj->autorenew_checkouts(1)->store; |
717 |
|
717 |
|
718 |
# Change policy so that loans can only be renewed exactly on due date (0 days prior to due date) |
718 |
# Change policy so that loans can only be renewed exactly on due date (0 days prior to due date) |
Lines 721-734
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
721 |
( $renewokay, $error ) = |
721 |
( $renewokay, $error ) = |
722 |
CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
722 |
CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
723 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' ); |
723 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' ); |
724 |
is( $error, 'auto_too_soon', |
724 |
is( $error->[0], 'auto_too_soon', |
725 |
'Bug 14101: Cannot renew, renewal is automatic and premature, "No renewal before" = 0 (returned code is auto_too_soon)' |
725 |
'Bug 14101: Cannot renew, renewal is automatic and premature, "No renewal before" = 0 (returned code is auto_too_soon)' |
726 |
); |
726 |
); |
727 |
|
727 |
|
728 |
$renewing_borrower_obj->autorenew_checkouts(0)->store; |
728 |
$renewing_borrower_obj->autorenew_checkouts(0)->store; |
729 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
729 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
730 |
is( $renewokay, 0, 'No renewal before is 0, patron opted out of auto_renewal still cannot renew early' ); |
730 |
is( $renewokay, 0, 'No renewal before is 0, patron opted out of auto_renewal still cannot renew early' ); |
731 |
is( $error, 'too_soon', 'Error is too_soon, no auto' ); |
731 |
is( $error->[0], 'too_soon', 'Error is too_soon, no auto' ); |
732 |
$renewing_borrower_obj->autorenew_checkouts(1)->store; |
732 |
$renewing_borrower_obj->autorenew_checkouts(1)->store; |
733 |
|
733 |
|
734 |
# Change policy so that loans can be renewed 99 days prior to the due date |
734 |
# Change policy so that loans can be renewed 99 days prior to the due date |
Lines 737-743
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
737 |
( $renewokay, $error ) = |
737 |
( $renewokay, $error ) = |
738 |
CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
738 |
CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
739 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic' ); |
739 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic' ); |
740 |
is( $error, 'auto_renew', |
740 |
is( $error->[0], 'auto_renew', |
741 |
'Bug 14101: Cannot renew, renewal is automatic (returned code is auto_renew)' |
741 |
'Bug 14101: Cannot renew, renewal is automatic (returned code is auto_renew)' |
742 |
); |
742 |
); |
743 |
|
743 |
|
Lines 776-782
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
776 |
( $renewokay, $error ) = |
776 |
( $renewokay, $error ) = |
777 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
777 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
778 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
778 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
779 |
is( $error, 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' ); |
779 |
is( $error->[0], 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' ); |
780 |
|
780 |
|
781 |
Koha::CirculationRules->set_rules( |
781 |
Koha::CirculationRules->set_rules( |
782 |
{ |
782 |
{ |
Lines 792-798
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
792 |
( $renewokay, $error ) = |
792 |
( $renewokay, $error ) = |
793 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
793 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
794 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
794 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
795 |
is( $error, 'auto_too_late', 'Cannot auto renew, too late - no_auto_renewal_after is inclusive(returned code is auto_too_late)' ); |
795 |
is( $error->[0], 'auto_too_late', 'Cannot auto renew, too late - no_auto_renewal_after is inclusive(returned code is auto_too_late)' ); |
796 |
|
796 |
|
797 |
Koha::CirculationRules->set_rules( |
797 |
Koha::CirculationRules->set_rules( |
798 |
{ |
798 |
{ |
Lines 808-814
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
808 |
( $renewokay, $error ) = |
808 |
( $renewokay, $error ) = |
809 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
809 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
810 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
810 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
811 |
is( $error, 'auto_too_soon', 'Cannot auto renew, too soon - no_auto_renewal_after is defined(returned code is auto_too_soon)' ); |
811 |
is( $error->[0], 'auto_too_soon', 'Cannot auto renew, too soon - no_auto_renewal_after is defined(returned code is auto_too_soon)' ); |
812 |
|
812 |
|
813 |
Koha::CirculationRules->set_rules( |
813 |
Koha::CirculationRules->set_rules( |
814 |
{ |
814 |
{ |
Lines 824-830
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
824 |
( $renewokay, $error ) = |
824 |
( $renewokay, $error ) = |
825 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
825 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
826 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
826 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
827 |
is( $error, 'auto_renew', 'Cannot renew, renew is automatic' ); |
827 |
is( $error->[0], 'auto_renew', 'Cannot renew, renew is automatic' ); |
828 |
|
828 |
|
829 |
Koha::CirculationRules->set_rules( |
829 |
Koha::CirculationRules->set_rules( |
830 |
{ |
830 |
{ |
Lines 841-847
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
841 |
( $renewokay, $error ) = |
841 |
( $renewokay, $error ) = |
842 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
842 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
843 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
843 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
844 |
is( $error, 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' ); |
844 |
is( $error->[0], 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' ); |
845 |
|
845 |
|
846 |
Koha::CirculationRules->set_rules( |
846 |
Koha::CirculationRules->set_rules( |
847 |
{ |
847 |
{ |
Lines 858-864
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
858 |
( $renewokay, $error ) = |
858 |
( $renewokay, $error ) = |
859 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
859 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
860 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
860 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
861 |
is( $error, 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' ); |
861 |
is( $error->[0], 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' ); |
862 |
|
862 |
|
863 |
Koha::CirculationRules->set_rules( |
863 |
Koha::CirculationRules->set_rules( |
864 |
{ |
864 |
{ |
Lines 875-881
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
875 |
( $renewokay, $error ) = |
875 |
( $renewokay, $error ) = |
876 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
876 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
877 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
877 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
878 |
is( $error, 'auto_renew', 'Cannot renew, renew is automatic' ); |
878 |
is( $error->[0], 'auto_renew', 'Cannot renew, renew is automatic' ); |
879 |
}; |
879 |
}; |
880 |
|
880 |
|
881 |
subtest "auto_too_much_oweing | OPACFineNoRenewalsBlockAutoRenew & OPACFineNoRenewalsIncludeCredit" => sub { |
881 |
subtest "auto_too_much_oweing | OPACFineNoRenewalsBlockAutoRenew & OPACFineNoRenewalsIncludeCredit" => sub { |
Lines 921-927
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
921 |
( $renewokay, $error ) = |
921 |
( $renewokay, $error ) = |
922 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
922 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
923 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
923 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
924 |
is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 5' ); |
924 |
is( $error->[0], 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 5' ); |
925 |
|
925 |
|
926 |
$account->add_debit( |
926 |
$account->add_debit( |
927 |
{ |
927 |
{ |
Lines 935-941
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
935 |
( $renewokay, $error ) = |
935 |
( $renewokay, $error ) = |
936 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
936 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
937 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
937 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
938 |
is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 10' ); |
938 |
is( $error->[0], 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 10' ); |
939 |
|
939 |
|
940 |
$account->add_debit( |
940 |
$account->add_debit( |
941 |
{ |
941 |
{ |
Lines 949-955
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
949 |
( $renewokay, $error ) = |
949 |
( $renewokay, $error ) = |
950 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
950 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
951 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
951 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
952 |
is( $error, 'auto_too_much_oweing', 'Cannot auto renew, OPACFineNoRenewals=10, patron has 15' ); |
952 |
is( $error->[0], 'auto_too_much_oweing', 'Cannot auto renew, OPACFineNoRenewals=10, patron has 15' ); |
953 |
|
953 |
|
954 |
$account->add_credit( |
954 |
$account->add_credit( |
955 |
{ |
955 |
{ |
Lines 962-974
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
962 |
( $renewokay, $error ) = |
962 |
( $renewokay, $error ) = |
963 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
963 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
964 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
964 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
965 |
is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, OPACFineNoRenewalsIncludeCredit=1, patron has 15 debt, 5 credit' ); |
965 |
is( $error->[0], 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, OPACFineNoRenewalsIncludeCredit=1, patron has 15 debt, 5 credit' ); |
966 |
|
966 |
|
967 |
C4::Context->set_preference('OPACFineNoRenewalsIncludeCredit','0'); |
967 |
C4::Context->set_preference('OPACFineNoRenewalsIncludeCredit','0'); |
968 |
( $renewokay, $error ) = |
968 |
( $renewokay, $error ) = |
969 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
969 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
970 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
970 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
971 |
is( $error, 'auto_too_much_oweing', 'Cannot auto renew, OPACFineNoRenewals=10, OPACFineNoRenewalsIncludeCredit=1, patron has 15 debt, 5 credit' ); |
971 |
is( $error->[0], 'auto_too_much_oweing', 'Cannot auto renew, OPACFineNoRenewals=10, OPACFineNoRenewalsIncludeCredit=1, patron has 15 debt, 5 credit' ); |
972 |
|
972 |
|
973 |
$dbh->do('DELETE FROM accountlines WHERE borrowernumber=?', undef, $renewing_borrowernumber); |
973 |
$dbh->do('DELETE FROM accountlines WHERE borrowernumber=?', undef, $renewing_borrowernumber); |
974 |
C4::Context->set_preference('OPACFineNoRenewalsIncludeCredit','1'); |
974 |
C4::Context->set_preference('OPACFineNoRenewalsIncludeCredit','1'); |
Lines 1008-1014
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
1008 |
( $renewokay, $error ) = |
1008 |
( $renewokay, $error ) = |
1009 |
CanBookBeRenewed( $patron->{borrowernumber}, $item_to_auto_renew->{itemnumber} ); |
1009 |
CanBookBeRenewed( $patron->{borrowernumber}, $item_to_auto_renew->{itemnumber} ); |
1010 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
1010 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
1011 |
is( $error, 'auto_renew', 'Can auto renew, patron is expired but BlockExpiredPatronOpacActions=0' ); |
1011 |
is( $error->[0], 'auto_renew', 'Can auto renew, patron is expired but BlockExpiredPatronOpacActions=0' ); |
1012 |
Koha::Checkouts->find( $checkout->issue_id )->delete; |
1012 |
Koha::Checkouts->find( $checkout->issue_id )->delete; |
1013 |
|
1013 |
|
1014 |
|
1014 |
|
Lines 1020-1026
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
1020 |
( $renewokay, $error ) = |
1020 |
( $renewokay, $error ) = |
1021 |
CanBookBeRenewed( $patron->{borrowernumber}, $item_to_auto_renew->{itemnumber} ); |
1021 |
CanBookBeRenewed( $patron->{borrowernumber}, $item_to_auto_renew->{itemnumber} ); |
1022 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
1022 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
1023 |
is( $error, 'auto_account_expired', 'Can not auto renew, lockExpiredPatronOpacActions=1 and patron is expired' ); |
1023 |
is( $error->[0], 'auto_account_expired', 'Can not auto renew, lockExpiredPatronOpacActions=1 and patron is expired' ); |
1024 |
Koha::Checkouts->find( $checkout->issue_id )->delete; |
1024 |
Koha::Checkouts->find( $checkout->issue_id )->delete; |
1025 |
|
1025 |
|
1026 |
|
1026 |
|
Lines 1032-1038
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
1032 |
( $renewokay, $error ) = |
1032 |
( $renewokay, $error ) = |
1033 |
CanBookBeRenewed( $patron->{borrowernumber}, $item_to_auto_renew->{itemnumber} ); |
1033 |
CanBookBeRenewed( $patron->{borrowernumber}, $item_to_auto_renew->{itemnumber} ); |
1034 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
1034 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
1035 |
is( $error, 'auto_renew', 'Can auto renew, BlockExpiredPatronOpacActions=1 but patron is not expired' ); |
1035 |
is( $error->[0], 'auto_renew', 'Can auto renew, BlockExpiredPatronOpacActions=1 but patron is not expired' ); |
1036 |
Koha::Checkouts->find( $checkout->issue_id )->delete; |
1036 |
Koha::Checkouts->find( $checkout->issue_id )->delete; |
1037 |
}; |
1037 |
}; |
1038 |
|
1038 |
|
Lines 1158-1164
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
1158 |
|
1158 |
|
1159 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber); |
1159 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber); |
1160 |
is( $renewokay, 0, 'Cannot renew, 0 renewals allowed'); |
1160 |
is( $renewokay, 0, 'Cannot renew, 0 renewals allowed'); |
1161 |
is( $error, 'too_many', 'Cannot renew, 0 renewals allowed (returned code is too_many)'); |
1161 |
is( $error->[0], 'too_many', 'Cannot renew, 0 renewals allowed (returned code is too_many)'); |
1162 |
|
1162 |
|
1163 |
# Test WhenLostForgiveFine and WhenLostChargeReplacementFee |
1163 |
# Test WhenLostForgiveFine and WhenLostChargeReplacementFee |
1164 |
t::lib::Mocks::mock_preference('WhenLostForgiveFine','1'); |
1164 |
t::lib::Mocks::mock_preference('WhenLostForgiveFine','1'); |
Lines 1547-1553
subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
Link Here
|
1547 |
my $issue = AddIssue( $borrower, $item->barcode, undef, undef, undef, undef, { onsite_checkout => 1 } ); |
1547 |
my $issue = AddIssue( $borrower, $item->barcode, undef, undef, undef, undef, { onsite_checkout => 1 } ); |
1548 |
my ( $renewed, $error ) = CanBookBeRenewed( $borrowernumber, $item->itemnumber ); |
1548 |
my ( $renewed, $error ) = CanBookBeRenewed( $borrowernumber, $item->itemnumber ); |
1549 |
is( $renewed, 0, 'CanBookBeRenewed should not allow to renew on-site checkout' ); |
1549 |
is( $renewed, 0, 'CanBookBeRenewed should not allow to renew on-site checkout' ); |
1550 |
is( $error, 'onsite_checkout', 'A correct error code should be returned by CanBookBeRenewed for on-site checkout' ); |
1550 |
is( $error->[0], 'onsite_checkout', 'A correct error code should be returned by CanBookBeRenewed for on-site checkout' ); |
1551 |
} |
1551 |
} |
1552 |
|
1552 |
|
1553 |
{ |
1553 |
{ |
Lines 3415-3421
subtest 'ItemsDeniedRenewal preference' => sub {
Link Here
|
3415 |
( $idr_mayrenew, $idr_error ) = |
3415 |
( $idr_mayrenew, $idr_error ) = |
3416 |
CanBookBeRenewed( $idr_borrower->borrowernumber, $deny_issue->itemnumber ); |
3416 |
CanBookBeRenewed( $idr_borrower->borrowernumber, $deny_issue->itemnumber ); |
3417 |
is( $idr_mayrenew, 0, 'Renewal blocked when 1 rules (withdrawn)' ); |
3417 |
is( $idr_mayrenew, 0, 'Renewal blocked when 1 rules (withdrawn)' ); |
3418 |
is( $idr_error, 'item_denied_renewal', 'Renewal blocked when 1 rule (withdrawn)' ); |
3418 |
is( $idr_error->[0], 'item_denied_renewal', 'Renewal blocked when 1 rule (withdrawn)' ); |
3419 |
( $idr_mayrenew, $idr_error ) = |
3419 |
( $idr_mayrenew, $idr_error ) = |
3420 |
CanBookBeRenewed( $idr_borrower->borrowernumber, $allow_issue->itemnumber ); |
3420 |
CanBookBeRenewed( $idr_borrower->borrowernumber, $allow_issue->itemnumber ); |
3421 |
is( $idr_mayrenew, 1, 'Renewal allowed when 1 rules not matched (withdrawn)' ); |
3421 |
is( $idr_mayrenew, 1, 'Renewal allowed when 1 rules not matched (withdrawn)' ); |
Lines 3427-3433
subtest 'ItemsDeniedRenewal preference' => sub {
Link Here
|
3427 |
( $idr_mayrenew, $idr_error ) = |
3427 |
( $idr_mayrenew, $idr_error ) = |
3428 |
CanBookBeRenewed( $idr_borrower->borrowernumber, $deny_issue->itemnumber ); |
3428 |
CanBookBeRenewed( $idr_borrower->borrowernumber, $deny_issue->itemnumber ); |
3429 |
is( $idr_mayrenew, 0, 'Renewal blocked when 2 rules matched (withdrawn, itype)' ); |
3429 |
is( $idr_mayrenew, 0, 'Renewal blocked when 2 rules matched (withdrawn, itype)' ); |
3430 |
is( $idr_error, 'item_denied_renewal', 'Renewal blocked when 2 rules matched (withdrawn,itype)' ); |
3430 |
is( $idr_error->[0], 'item_denied_renewal', 'Renewal blocked when 2 rules matched (withdrawn,itype)' ); |
3431 |
( $idr_mayrenew, $idr_error ) = |
3431 |
( $idr_mayrenew, $idr_error ) = |
3432 |
CanBookBeRenewed( $idr_borrower->borrowernumber, $allow_issue->itemnumber ); |
3432 |
CanBookBeRenewed( $idr_borrower->borrowernumber, $allow_issue->itemnumber ); |
3433 |
is( $idr_mayrenew, 1, 'Renewal allowed when 2 rules not matched (withdrawn, itype)' ); |
3433 |
is( $idr_mayrenew, 1, 'Renewal allowed when 2 rules not matched (withdrawn, itype)' ); |
Lines 3439-3445
subtest 'ItemsDeniedRenewal preference' => sub {
Link Here
|
3439 |
( $idr_mayrenew, $idr_error ) = |
3439 |
( $idr_mayrenew, $idr_error ) = |
3440 |
CanBookBeRenewed( $idr_borrower->borrowernumber, $deny_issue->itemnumber ); |
3440 |
CanBookBeRenewed( $idr_borrower->borrowernumber, $deny_issue->itemnumber ); |
3441 |
is( $idr_mayrenew, 0, 'Renewal blocked when 3 rules matched (withdrawn, itype, location)' ); |
3441 |
is( $idr_mayrenew, 0, 'Renewal blocked when 3 rules matched (withdrawn, itype, location)' ); |
3442 |
is( $idr_error, 'item_denied_renewal', 'Renewal blocked when 3 rules matched (withdrawn,itype, location)' ); |
3442 |
is( $idr_error->[0], 'item_denied_renewal', 'Renewal blocked when 3 rules matched (withdrawn,itype, location)' ); |
3443 |
( $idr_mayrenew, $idr_error ) = |
3443 |
( $idr_mayrenew, $idr_error ) = |
3444 |
CanBookBeRenewed( $idr_borrower->borrowernumber, $allow_issue->itemnumber ); |
3444 |
CanBookBeRenewed( $idr_borrower->borrowernumber, $allow_issue->itemnumber ); |
3445 |
is( $idr_mayrenew, 1, 'Renewal allowed when 3 rules not matched (withdrawn, itype, location)' ); |
3445 |
is( $idr_mayrenew, 1, 'Renewal allowed when 3 rules not matched (withdrawn, itype, location)' ); |
3446 |
- |
|
|