|
Lines 448-458
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
| 448 |
|
448 |
|
| 449 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber); |
449 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber); |
| 450 |
is( $renewokay, 0, '(Bug 10663) Cannot renew, reserved'); |
450 |
is( $renewokay, 0, '(Bug 10663) Cannot renew, reserved'); |
| 451 |
is( $error, 'on_reserve', '(Bug 10663) Cannot renew, reserved (returned error is on_reserve)'); |
451 |
is( $error->[0], 'on_reserve', '(Bug 10663) Cannot renew, reserved (returned error is on_reserve)'); |
| 452 |
|
452 |
|
| 453 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_2->itemnumber); |
453 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_2->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 |
my $reserveid = Koha::Holds->search({ biblionumber => $biblio->biblionumber, borrowernumber => $reserving_borrowernumber })->next->reserve_id; |
457 |
my $reserveid = Koha::Holds->search({ biblionumber => $biblio->biblionumber, borrowernumber => $reserving_borrowernumber })->next->reserve_id; |
| 458 |
my $reserving_borrower = Koha::Patrons->find( $reserving_borrowernumber )->unblessed; |
458 |
my $reserving_borrower = Koha::Patrons->find( $reserving_borrowernumber )->unblessed; |
|
Lines 481-487
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
| 481 |
|
481 |
|
| 482 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber, 1); |
482 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber, 1); |
| 483 |
is( $renewokay, 0, '(Bug 10663) Cannot renew, item reserved'); |
483 |
is( $renewokay, 0, '(Bug 10663) Cannot renew, item reserved'); |
| 484 |
is( $error, 'on_reserve', '(Bug 10663) Cannot renew, item reserved (returned error is on_reserve)'); |
484 |
is( $error->[0], 'on_reserve', '(Bug 10663) Cannot renew, item reserved (returned error is on_reserve)'); |
| 485 |
|
485 |
|
| 486 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_2->itemnumber, 1); |
486 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_2->itemnumber, 1); |
| 487 |
is( $renewokay, 1, 'Can renew item 2, item-level hold is on item 1'); |
487 |
is( $renewokay, 1, 'Can renew item 2, item-level hold is on item 1'); |
|
Lines 625-631
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
| 625 |
( $renewokay, $error ) = |
625 |
( $renewokay, $error ) = |
| 626 |
CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
626 |
CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
| 627 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' ); |
627 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' ); |
| 628 |
is( $error, 'auto_too_soon', |
628 |
is( $error->[0], 'auto_too_soon', |
| 629 |
'Bug 14101: Cannot renew, renewal is automatic and premature, "No renewal before" = undef (returned code is auto_too_soon)' ); |
629 |
'Bug 14101: Cannot renew, renewal is automatic and premature, "No renewal before" = undef (returned code is auto_too_soon)' ); |
| 630 |
AddReserve( |
630 |
AddReserve( |
| 631 |
{ |
631 |
{ |
|
Lines 644-657
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
| 644 |
); |
644 |
); |
| 645 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
645 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
| 646 |
is( $renewokay, 0, 'Still should not be able to renew' ); |
646 |
is( $renewokay, 0, 'Still should not be able to renew' ); |
| 647 |
is( $error, 'auto_too_soon', 'returned code is auto_too_soon, reserve not checked' ); |
647 |
is( $error->[0], 'auto_too_soon', 'returned code is auto_too_soon, reserve not checked' ); |
| 648 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber, 1 ); |
648 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber, 1 ); |
| 649 |
is( $renewokay, 0, 'Still should not be able to renew' ); |
649 |
is( $renewokay, 0, 'Still should not be able to renew' ); |
| 650 |
is( $error, 'on_reserve', 'returned code is on_reserve, auto_too_soon limit is overridden' ); |
650 |
is( $error->[0], 'on_reserve', 'returned code is on_reserve, auto_too_soon limit is overridden' ); |
| 651 |
$dbh->do('UPDATE circulation_rules SET rule_value = 0 where rule_name = "norenewalbefore"'); |
651 |
$dbh->do('UPDATE circulation_rules SET rule_value = 0 where rule_name = "norenewalbefore"'); |
| 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_renew only happens if not on reserve' ); |
654 |
is( $error->[0], 'on_reserve', 'returned code is on_reserve, auto_renew only happens if not on reserve' ); |
| 655 |
ModReserveCancelAll($item_4->itemnumber, $reserving_borrowernumber); |
655 |
ModReserveCancelAll($item_4->itemnumber, $reserving_borrowernumber); |
| 656 |
|
656 |
|
| 657 |
|
657 |
|
|
Lines 676-682
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
| 676 |
|
676 |
|
| 677 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber); |
677 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber); |
| 678 |
is( $renewokay, 0, 'Bug 7413: Cannot renew, renewal is premature'); |
678 |
is( $renewokay, 0, 'Bug 7413: Cannot renew, renewal is premature'); |
| 679 |
is( $error, 'too_soon', 'Bug 7413: Cannot renew, renewal is premature (returned code is too_soon)'); |
679 |
is( $error->[0], 'too_soon', 'Bug 7413: Cannot renew, renewal is premature (returned code is too_soon)'); |
| 680 |
|
680 |
|
| 681 |
# Bug 14395 |
681 |
# Bug 14395 |
| 682 |
# Test 'exact time' setting for syspref NoRenewalBeforePrecision |
682 |
# Test 'exact time' setting for syspref NoRenewalBeforePrecision |
|
Lines 701-714
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
| 701 |
( $renewokay, $error ) = |
701 |
( $renewokay, $error ) = |
| 702 |
CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
702 |
CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
| 703 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' ); |
703 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' ); |
| 704 |
is( $error, 'auto_too_soon', |
704 |
is( $error->[0], 'auto_too_soon', |
| 705 |
'Bug 14101: Cannot renew, renewal is automatic and premature (returned code is auto_too_soon)' |
705 |
'Bug 14101: Cannot renew, renewal is automatic and premature (returned code is auto_too_soon)' |
| 706 |
); |
706 |
); |
| 707 |
|
707 |
|
| 708 |
$renewing_borrower_obj->autorenew_checkouts(0)->store; |
708 |
$renewing_borrower_obj->autorenew_checkouts(0)->store; |
| 709 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
709 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
| 710 |
is( $renewokay, 0, 'No renewal before is 7, patron opted out of auto_renewal still cannot renew early' ); |
710 |
is( $renewokay, 0, 'No renewal before is 7, patron opted out of auto_renewal still cannot renew early' ); |
| 711 |
is( $error, 'too_soon', 'Error is too_soon, no auto' ); |
711 |
is( $error->[0], 'too_soon', 'Error is too_soon, no auto' ); |
| 712 |
$renewing_borrower_obj->autorenew_checkouts(1)->store; |
712 |
$renewing_borrower_obj->autorenew_checkouts(1)->store; |
| 713 |
|
713 |
|
| 714 |
# Change policy so that loans can only be renewed exactly on due date (0 days prior to due date) |
714 |
# Change policy so that loans can only be renewed exactly on due date (0 days prior to due date) |
|
Lines 717-730
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
| 717 |
( $renewokay, $error ) = |
717 |
( $renewokay, $error ) = |
| 718 |
CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
718 |
CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
| 719 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' ); |
719 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' ); |
| 720 |
is( $error, 'auto_too_soon', |
720 |
is( $error->[0], 'auto_too_soon', |
| 721 |
'Bug 14101: Cannot renew, renewal is automatic and premature, "No renewal before" = 0 (returned code is auto_too_soon)' |
721 |
'Bug 14101: Cannot renew, renewal is automatic and premature, "No renewal before" = 0 (returned code is auto_too_soon)' |
| 722 |
); |
722 |
); |
| 723 |
|
723 |
|
| 724 |
$renewing_borrower_obj->autorenew_checkouts(0)->store; |
724 |
$renewing_borrower_obj->autorenew_checkouts(0)->store; |
| 725 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
725 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
| 726 |
is( $renewokay, 0, 'No renewal before is 0, patron opted out of auto_renewal still cannot renew early' ); |
726 |
is( $renewokay, 0, 'No renewal before is 0, patron opted out of auto_renewal still cannot renew early' ); |
| 727 |
is( $error, 'too_soon', 'Error is too_soon, no auto' ); |
727 |
is( $error->[0], 'too_soon', 'Error is too_soon, no auto' ); |
| 728 |
$renewing_borrower_obj->autorenew_checkouts(1)->store; |
728 |
$renewing_borrower_obj->autorenew_checkouts(1)->store; |
| 729 |
|
729 |
|
| 730 |
# Change policy so that loans can be renewed 99 days prior to the due date |
730 |
# Change policy so that loans can be renewed 99 days prior to the due date |
|
Lines 733-739
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
| 733 |
( $renewokay, $error ) = |
733 |
( $renewokay, $error ) = |
| 734 |
CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
734 |
CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
| 735 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic' ); |
735 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic' ); |
| 736 |
is( $error, 'auto_renew', |
736 |
is( $error->[0], 'auto_renew', |
| 737 |
'Bug 14101: Cannot renew, renewal is automatic (returned code is auto_renew)' |
737 |
'Bug 14101: Cannot renew, renewal is automatic (returned code is auto_renew)' |
| 738 |
); |
738 |
); |
| 739 |
|
739 |
|
|
Lines 772-778
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
| 772 |
( $renewokay, $error ) = |
772 |
( $renewokay, $error ) = |
| 773 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
773 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 774 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
774 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 775 |
is( $error, 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' ); |
775 |
is( $error->[0], 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' ); |
| 776 |
|
776 |
|
| 777 |
Koha::CirculationRules->set_rules( |
777 |
Koha::CirculationRules->set_rules( |
| 778 |
{ |
778 |
{ |
|
Lines 788-794
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
| 788 |
( $renewokay, $error ) = |
788 |
( $renewokay, $error ) = |
| 789 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
789 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 790 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
790 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 791 |
is( $error, 'auto_too_late', 'Cannot auto renew, too late - no_auto_renewal_after is inclusive(returned code is auto_too_late)' ); |
791 |
is( $error->[0], 'auto_too_late', 'Cannot auto renew, too late - no_auto_renewal_after is inclusive(returned code is auto_too_late)' ); |
| 792 |
|
792 |
|
| 793 |
Koha::CirculationRules->set_rules( |
793 |
Koha::CirculationRules->set_rules( |
| 794 |
{ |
794 |
{ |
|
Lines 804-810
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
| 804 |
( $renewokay, $error ) = |
804 |
( $renewokay, $error ) = |
| 805 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
805 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 806 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
806 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 807 |
is( $error, 'auto_too_soon', 'Cannot auto renew, too soon - no_auto_renewal_after is defined(returned code is auto_too_soon)' ); |
807 |
is( $error->[0], 'auto_too_soon', 'Cannot auto renew, too soon - no_auto_renewal_after is defined(returned code is auto_too_soon)' ); |
| 808 |
|
808 |
|
| 809 |
Koha::CirculationRules->set_rules( |
809 |
Koha::CirculationRules->set_rules( |
| 810 |
{ |
810 |
{ |
|
Lines 820-826
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
| 820 |
( $renewokay, $error ) = |
820 |
( $renewokay, $error ) = |
| 821 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
821 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 822 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
822 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 823 |
is( $error, 'auto_renew', 'Cannot renew, renew is automatic' ); |
823 |
is( $error->[0], 'auto_renew', 'Cannot renew, renew is automatic' ); |
| 824 |
|
824 |
|
| 825 |
Koha::CirculationRules->set_rules( |
825 |
Koha::CirculationRules->set_rules( |
| 826 |
{ |
826 |
{ |
|
Lines 837-843
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
| 837 |
( $renewokay, $error ) = |
837 |
( $renewokay, $error ) = |
| 838 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
838 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 839 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
839 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 840 |
is( $error, 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' ); |
840 |
is( $error->[0], 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' ); |
| 841 |
|
841 |
|
| 842 |
Koha::CirculationRules->set_rules( |
842 |
Koha::CirculationRules->set_rules( |
| 843 |
{ |
843 |
{ |
|
Lines 854-860
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
| 854 |
( $renewokay, $error ) = |
854 |
( $renewokay, $error ) = |
| 855 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
855 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 856 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
856 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 857 |
is( $error, 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' ); |
857 |
is( $error->[0], 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' ); |
| 858 |
|
858 |
|
| 859 |
Koha::CirculationRules->set_rules( |
859 |
Koha::CirculationRules->set_rules( |
| 860 |
{ |
860 |
{ |
|
Lines 871-877
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
| 871 |
( $renewokay, $error ) = |
871 |
( $renewokay, $error ) = |
| 872 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
872 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 873 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
873 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 874 |
is( $error, 'auto_renew', 'Cannot renew, renew is automatic' ); |
874 |
is( $error->[0], 'auto_renew', 'Cannot renew, renew is automatic' ); |
| 875 |
}; |
875 |
}; |
| 876 |
|
876 |
|
| 877 |
subtest "auto_too_much_oweing | OPACFineNoRenewalsBlockAutoRenew & OPACFineNoRenewalsIncludeCredit" => sub { |
877 |
subtest "auto_too_much_oweing | OPACFineNoRenewalsBlockAutoRenew & OPACFineNoRenewalsIncludeCredit" => sub { |
|
Lines 917-923
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
| 917 |
( $renewokay, $error ) = |
917 |
( $renewokay, $error ) = |
| 918 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
918 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 919 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
919 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 920 |
is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 5' ); |
920 |
is( $error->[0], 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 5' ); |
| 921 |
|
921 |
|
| 922 |
$account->add_debit( |
922 |
$account->add_debit( |
| 923 |
{ |
923 |
{ |
|
Lines 931-937
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
| 931 |
( $renewokay, $error ) = |
931 |
( $renewokay, $error ) = |
| 932 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
932 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 933 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
933 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 934 |
is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 10' ); |
934 |
is( $error->[0], 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 10' ); |
| 935 |
|
935 |
|
| 936 |
$account->add_debit( |
936 |
$account->add_debit( |
| 937 |
{ |
937 |
{ |
|
Lines 945-951
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
| 945 |
( $renewokay, $error ) = |
945 |
( $renewokay, $error ) = |
| 946 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
946 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 947 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
947 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 948 |
is( $error, 'auto_too_much_oweing', 'Cannot auto renew, OPACFineNoRenewals=10, patron has 15' ); |
948 |
is( $error->[0], 'auto_too_much_oweing', 'Cannot auto renew, OPACFineNoRenewals=10, patron has 15' ); |
| 949 |
|
949 |
|
| 950 |
$account->add_credit( |
950 |
$account->add_credit( |
| 951 |
{ |
951 |
{ |
|
Lines 958-970
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
| 958 |
( $renewokay, $error ) = |
958 |
( $renewokay, $error ) = |
| 959 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
959 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 960 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
960 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 961 |
is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, OPACFineNoRenewalsIncludeCredit=1, patron has 15 debt, 5 credit' ); |
961 |
is( $error->[0], 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, OPACFineNoRenewalsIncludeCredit=1, patron has 15 debt, 5 credit' ); |
| 962 |
|
962 |
|
| 963 |
C4::Context->set_preference('OPACFineNoRenewalsIncludeCredit','0'); |
963 |
C4::Context->set_preference('OPACFineNoRenewalsIncludeCredit','0'); |
| 964 |
( $renewokay, $error ) = |
964 |
( $renewokay, $error ) = |
| 965 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
965 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 966 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
966 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 967 |
is( $error, 'auto_too_much_oweing', 'Cannot auto renew, OPACFineNoRenewals=10, OPACFineNoRenewalsIncludeCredit=1, patron has 15 debt, 5 credit' ); |
967 |
is( $error->[0], 'auto_too_much_oweing', 'Cannot auto renew, OPACFineNoRenewals=10, OPACFineNoRenewalsIncludeCredit=1, patron has 15 debt, 5 credit' ); |
| 968 |
|
968 |
|
| 969 |
$dbh->do('DELETE FROM accountlines WHERE borrowernumber=?', undef, $renewing_borrowernumber); |
969 |
$dbh->do('DELETE FROM accountlines WHERE borrowernumber=?', undef, $renewing_borrowernumber); |
| 970 |
C4::Context->set_preference('OPACFineNoRenewalsIncludeCredit','1'); |
970 |
C4::Context->set_preference('OPACFineNoRenewalsIncludeCredit','1'); |
|
Lines 1004-1010
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
| 1004 |
( $renewokay, $error ) = |
1004 |
( $renewokay, $error ) = |
| 1005 |
CanBookBeRenewed( $patron->{borrowernumber}, $item_to_auto_renew->{itemnumber} ); |
1005 |
CanBookBeRenewed( $patron->{borrowernumber}, $item_to_auto_renew->{itemnumber} ); |
| 1006 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
1006 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 1007 |
is( $error, 'auto_renew', 'Can auto renew, patron is expired but BlockExpiredPatronOpacActions=0' ); |
1007 |
is( $error->[0], 'auto_renew', 'Can auto renew, patron is expired but BlockExpiredPatronOpacActions=0' ); |
| 1008 |
Koha::Checkouts->find( $checkout->issue_id )->delete; |
1008 |
Koha::Checkouts->find( $checkout->issue_id )->delete; |
| 1009 |
|
1009 |
|
| 1010 |
|
1010 |
|
|
Lines 1016-1022
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
| 1016 |
( $renewokay, $error ) = |
1016 |
( $renewokay, $error ) = |
| 1017 |
CanBookBeRenewed( $patron->{borrowernumber}, $item_to_auto_renew->{itemnumber} ); |
1017 |
CanBookBeRenewed( $patron->{borrowernumber}, $item_to_auto_renew->{itemnumber} ); |
| 1018 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
1018 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 1019 |
is( $error, 'auto_account_expired', 'Can not auto renew, lockExpiredPatronOpacActions=1 and patron is expired' ); |
1019 |
is( $error->[0], 'auto_account_expired', 'Can not auto renew, lockExpiredPatronOpacActions=1 and patron is expired' ); |
| 1020 |
Koha::Checkouts->find( $checkout->issue_id )->delete; |
1020 |
Koha::Checkouts->find( $checkout->issue_id )->delete; |
| 1021 |
|
1021 |
|
| 1022 |
|
1022 |
|
|
Lines 1028-1034
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
| 1028 |
( $renewokay, $error ) = |
1028 |
( $renewokay, $error ) = |
| 1029 |
CanBookBeRenewed( $patron->{borrowernumber}, $item_to_auto_renew->{itemnumber} ); |
1029 |
CanBookBeRenewed( $patron->{borrowernumber}, $item_to_auto_renew->{itemnumber} ); |
| 1030 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
1030 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 1031 |
is( $error, 'auto_renew', 'Can auto renew, BlockExpiredPatronOpacActions=1 but patron is not expired' ); |
1031 |
is( $error->[0], 'auto_renew', 'Can auto renew, BlockExpiredPatronOpacActions=1 but patron is not expired' ); |
| 1032 |
Koha::Checkouts->find( $checkout->issue_id )->delete; |
1032 |
Koha::Checkouts->find( $checkout->issue_id )->delete; |
| 1033 |
}; |
1033 |
}; |
| 1034 |
|
1034 |
|
|
Lines 1154-1160
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
| 1154 |
|
1154 |
|
| 1155 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber); |
1155 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber); |
| 1156 |
is( $renewokay, 0, 'Cannot renew, 0 renewals allowed'); |
1156 |
is( $renewokay, 0, 'Cannot renew, 0 renewals allowed'); |
| 1157 |
is( $error, 'too_many', 'Cannot renew, 0 renewals allowed (returned code is too_many)'); |
1157 |
is( $error->[0], 'too_many', 'Cannot renew, 0 renewals allowed (returned code is too_many)'); |
| 1158 |
|
1158 |
|
| 1159 |
# Test WhenLostForgiveFine and WhenLostChargeReplacementFee |
1159 |
# Test WhenLostForgiveFine and WhenLostChargeReplacementFee |
| 1160 |
t::lib::Mocks::mock_preference('WhenLostForgiveFine','1'); |
1160 |
t::lib::Mocks::mock_preference('WhenLostForgiveFine','1'); |
|
Lines 1543-1549
subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
Link Here
|
| 1543 |
my $issue = AddIssue( $borrower, $item->barcode, undef, undef, undef, undef, { onsite_checkout => 1 } ); |
1543 |
my $issue = AddIssue( $borrower, $item->barcode, undef, undef, undef, undef, { onsite_checkout => 1 } ); |
| 1544 |
my ( $renewed, $error ) = CanBookBeRenewed( $borrowernumber, $item->itemnumber ); |
1544 |
my ( $renewed, $error ) = CanBookBeRenewed( $borrowernumber, $item->itemnumber ); |
| 1545 |
is( $renewed, 0, 'CanBookBeRenewed should not allow to renew on-site checkout' ); |
1545 |
is( $renewed, 0, 'CanBookBeRenewed should not allow to renew on-site checkout' ); |
| 1546 |
is( $error, 'onsite_checkout', 'A correct error code should be returned by CanBookBeRenewed for on-site checkout' ); |
1546 |
is( $error->[0], 'onsite_checkout', 'A correct error code should be returned by CanBookBeRenewed for on-site checkout' ); |
| 1547 |
} |
1547 |
} |
| 1548 |
|
1548 |
|
| 1549 |
{ |
1549 |
{ |
|
Lines 3236-3242
subtest 'ItemsDeniedRenewal preference' => sub {
Link Here
|
| 3236 |
( $idr_mayrenew, $idr_error ) = |
3236 |
( $idr_mayrenew, $idr_error ) = |
| 3237 |
CanBookBeRenewed( $idr_borrower->borrowernumber, $deny_issue->itemnumber ); |
3237 |
CanBookBeRenewed( $idr_borrower->borrowernumber, $deny_issue->itemnumber ); |
| 3238 |
is( $idr_mayrenew, 0, 'Renewal blocked when 1 rules (withdrawn)' ); |
3238 |
is( $idr_mayrenew, 0, 'Renewal blocked when 1 rules (withdrawn)' ); |
| 3239 |
is( $idr_error, 'item_denied_renewal', 'Renewal blocked when 1 rule (withdrawn)' ); |
3239 |
is( $idr_error->[0], 'item_denied_renewal', 'Renewal blocked when 1 rule (withdrawn)' ); |
| 3240 |
( $idr_mayrenew, $idr_error ) = |
3240 |
( $idr_mayrenew, $idr_error ) = |
| 3241 |
CanBookBeRenewed( $idr_borrower->borrowernumber, $allow_issue->itemnumber ); |
3241 |
CanBookBeRenewed( $idr_borrower->borrowernumber, $allow_issue->itemnumber ); |
| 3242 |
is( $idr_mayrenew, 1, 'Renewal allowed when 1 rules not matched (withdrawn)' ); |
3242 |
is( $idr_mayrenew, 1, 'Renewal allowed when 1 rules not matched (withdrawn)' ); |
|
Lines 3248-3254
subtest 'ItemsDeniedRenewal preference' => sub {
Link Here
|
| 3248 |
( $idr_mayrenew, $idr_error ) = |
3248 |
( $idr_mayrenew, $idr_error ) = |
| 3249 |
CanBookBeRenewed( $idr_borrower->borrowernumber, $deny_issue->itemnumber ); |
3249 |
CanBookBeRenewed( $idr_borrower->borrowernumber, $deny_issue->itemnumber ); |
| 3250 |
is( $idr_mayrenew, 0, 'Renewal blocked when 2 rules matched (withdrawn, itype)' ); |
3250 |
is( $idr_mayrenew, 0, 'Renewal blocked when 2 rules matched (withdrawn, itype)' ); |
| 3251 |
is( $idr_error, 'item_denied_renewal', 'Renewal blocked when 2 rules matched (withdrawn,itype)' ); |
3251 |
is( $idr_error->[0], 'item_denied_renewal', 'Renewal blocked when 2 rules matched (withdrawn,itype)' ); |
| 3252 |
( $idr_mayrenew, $idr_error ) = |
3252 |
( $idr_mayrenew, $idr_error ) = |
| 3253 |
CanBookBeRenewed( $idr_borrower->borrowernumber, $allow_issue->itemnumber ); |
3253 |
CanBookBeRenewed( $idr_borrower->borrowernumber, $allow_issue->itemnumber ); |
| 3254 |
is( $idr_mayrenew, 1, 'Renewal allowed when 2 rules not matched (withdrawn, itype)' ); |
3254 |
is( $idr_mayrenew, 1, 'Renewal allowed when 2 rules not matched (withdrawn, itype)' ); |
|
Lines 3260-3266
subtest 'ItemsDeniedRenewal preference' => sub {
Link Here
|
| 3260 |
( $idr_mayrenew, $idr_error ) = |
3260 |
( $idr_mayrenew, $idr_error ) = |
| 3261 |
CanBookBeRenewed( $idr_borrower->borrowernumber, $deny_issue->itemnumber ); |
3261 |
CanBookBeRenewed( $idr_borrower->borrowernumber, $deny_issue->itemnumber ); |
| 3262 |
is( $idr_mayrenew, 0, 'Renewal blocked when 3 rules matched (withdrawn, itype, location)' ); |
3262 |
is( $idr_mayrenew, 0, 'Renewal blocked when 3 rules matched (withdrawn, itype, location)' ); |
| 3263 |
is( $idr_error, 'item_denied_renewal', 'Renewal blocked when 3 rules matched (withdrawn,itype, location)' ); |
3263 |
is( $idr_error->[0], 'item_denied_renewal', 'Renewal blocked when 3 rules matched (withdrawn,itype, location)' ); |
| 3264 |
( $idr_mayrenew, $idr_error ) = |
3264 |
( $idr_mayrenew, $idr_error ) = |
| 3265 |
CanBookBeRenewed( $idr_borrower->borrowernumber, $allow_issue->itemnumber ); |
3265 |
CanBookBeRenewed( $idr_borrower->borrowernumber, $allow_issue->itemnumber ); |
| 3266 |
is( $idr_mayrenew, 1, 'Renewal allowed when 3 rules not matched (withdrawn, itype, location)' ); |
3266 |
is( $idr_mayrenew, 1, 'Renewal allowed when 3 rules not matched (withdrawn, itype, location)' ); |
| 3267 |
- |
|
|