Lines 355-361
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
355 |
my $restricted_borrowernumber = Koha::Patron->new(\%restricted_borrower_data)->store->borrowernumber; |
355 |
my $restricted_borrowernumber = Koha::Patron->new(\%restricted_borrower_data)->store->borrowernumber; |
356 |
my $expired_borrowernumber = Koha::Patron->new(\%expired_borrower_data)->store->borrowernumber; |
356 |
my $expired_borrowernumber = Koha::Patron->new(\%expired_borrower_data)->store->borrowernumber; |
357 |
|
357 |
|
358 |
my $renewing_borrower = Koha::Patrons->find( $renewing_borrowernumber )->unblessed; |
358 |
my $renewing_borrower_obj = Koha::Patrons->find( $renewing_borrowernumber ); |
|
|
359 |
my $renewing_borrower = $renewing_borrower_obj->unblessed; |
359 |
my $restricted_borrower = Koha::Patrons->find( $restricted_borrowernumber )->unblessed; |
360 |
my $restricted_borrower = Koha::Patrons->find( $restricted_borrowernumber )->unblessed; |
360 |
my $expired_borrower = Koha::Patrons->find( $expired_borrowernumber )->unblessed; |
361 |
my $expired_borrower = Koha::Patrons->find( $expired_borrowernumber )->unblessed; |
361 |
|
362 |
|
Lines 656-661
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
656 |
|
657 |
|
657 |
|
658 |
|
658 |
|
659 |
|
|
|
660 |
$renewing_borrower_obj->autorenewal(0)->store; |
661 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
662 |
is( $renewokay, 1, 'No renewal before is undef, but patron opted out of auto_renewal' ); |
663 |
$renewing_borrower_obj->autorenewal(1)->store; |
664 |
|
665 |
|
659 |
# Bug 7413 |
666 |
# Bug 7413 |
660 |
# Test premature manual renewal |
667 |
# Test premature manual renewal |
661 |
Koha::CirculationRules->set_rule( |
668 |
Koha::CirculationRules->set_rule( |
Lines 699-704
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
699 |
'Bug 14101: Cannot renew, renewal is automatic and premature (returned code is auto_too_soon)' |
706 |
'Bug 14101: Cannot renew, renewal is automatic and premature (returned code is auto_too_soon)' |
700 |
); |
707 |
); |
701 |
|
708 |
|
|
|
709 |
$renewing_borrower_obj->autorenewal(0)->store; |
710 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
711 |
is( $renewokay, 0, 'No renewal before is 7, patron opted out of auto_renewal still cannot renew early' ); |
712 |
is( $error, 'too_soon', 'Error is too_soon, no auto' ); |
713 |
$renewing_borrower_obj->autorenewal(1)->store; |
714 |
|
702 |
# Change policy so that loans can only be renewed exactly on due date (0 days prior to due date) |
715 |
# Change policy so that loans can only be renewed exactly on due date (0 days prior to due date) |
703 |
# and test automatic renewal again |
716 |
# and test automatic renewal again |
704 |
$dbh->do(q{UPDATE circulation_rules SET rule_value = '0' WHERE rule_name = 'norenewalbefore'}); |
717 |
$dbh->do(q{UPDATE circulation_rules SET rule_value = '0' WHERE rule_name = 'norenewalbefore'}); |
Lines 709-714
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
709 |
'Bug 14101: Cannot renew, renewal is automatic and premature, "No renewal before" = 0 (returned code is auto_too_soon)' |
722 |
'Bug 14101: Cannot renew, renewal is automatic and premature, "No renewal before" = 0 (returned code is auto_too_soon)' |
710 |
); |
723 |
); |
711 |
|
724 |
|
|
|
725 |
$renewing_borrower_obj->autorenewal(0)->store; |
726 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
727 |
is( $renewokay, 0, 'No renewal before is 0, patron opted out of auto_renewal still cannot renew early' ); |
728 |
is( $error, 'too_soon', 'Error is too_soon, no auto' ); |
729 |
$renewing_borrower_obj->autorenewal(1)->store; |
730 |
|
712 |
# Change policy so that loans can be renewed 99 days prior to the due date |
731 |
# Change policy so that loans can be renewed 99 days prior to the due date |
713 |
# and test automatic renewal again |
732 |
# and test automatic renewal again |
714 |
$dbh->do(q{UPDATE circulation_rules SET rule_value = '99' WHERE rule_name = 'norenewalbefore'}); |
733 |
$dbh->do(q{UPDATE circulation_rules SET rule_value = '99' WHERE rule_name = 'norenewalbefore'}); |
Lines 719-724
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
719 |
'Bug 14101: Cannot renew, renewal is automatic (returned code is auto_renew)' |
738 |
'Bug 14101: Cannot renew, renewal is automatic (returned code is auto_renew)' |
720 |
); |
739 |
); |
721 |
|
740 |
|
|
|
741 |
$renewing_borrower_obj->autorenewal(0)->store; |
742 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
743 |
is( $renewokay, 1, 'No renewal before is 99, patron opted out of auto_renewal so can renew' ); |
744 |
$renewing_borrower_obj->autorenewal(1)->store; |
745 |
|
722 |
subtest "too_late_renewal / no_auto_renewal_after" => sub { |
746 |
subtest "too_late_renewal / no_auto_renewal_after" => sub { |
723 |
plan tests => 14; |
747 |
plan tests => 14; |
724 |
my $item_to_auto_renew = $builder->build( |
748 |
my $item_to_auto_renew = $builder->build( |
725 |
- |
|
|