Lines 277-283
$dbh->do(
Link Here
|
277 |
|
277 |
|
278 |
my ( $reused_itemnumber_1, $reused_itemnumber_2 ); |
278 |
my ( $reused_itemnumber_1, $reused_itemnumber_2 ); |
279 |
subtest "CanBookBeRenewed tests" => sub { |
279 |
subtest "CanBookBeRenewed tests" => sub { |
280 |
plan tests => 71; |
280 |
plan tests => 77; |
281 |
|
281 |
|
282 |
C4::Context->set_preference('ItemsDeniedRenewal',''); |
282 |
C4::Context->set_preference('ItemsDeniedRenewal',''); |
283 |
# Generate test biblio |
283 |
# Generate test biblio |
Lines 358-364
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
358 |
my $restricted_borrowernumber = Koha::Patron->new(\%restricted_borrower_data)->store->borrowernumber; |
358 |
my $restricted_borrowernumber = Koha::Patron->new(\%restricted_borrower_data)->store->borrowernumber; |
359 |
my $expired_borrowernumber = Koha::Patron->new(\%expired_borrower_data)->store->borrowernumber; |
359 |
my $expired_borrowernumber = Koha::Patron->new(\%expired_borrower_data)->store->borrowernumber; |
360 |
|
360 |
|
361 |
my $renewing_borrower = Koha::Patrons->find( $renewing_borrowernumber )->unblessed; |
361 |
my $renewing_borrower_obj = Koha::Patrons->find( $renewing_borrowernumber ); |
|
|
362 |
my $renewing_borrower = $renewing_borrower_obj->unblessed; |
362 |
my $restricted_borrower = Koha::Patrons->find( $restricted_borrowernumber )->unblessed; |
363 |
my $restricted_borrower = Koha::Patrons->find( $restricted_borrowernumber )->unblessed; |
363 |
my $expired_borrower = Koha::Patrons->find( $expired_borrowernumber )->unblessed; |
364 |
my $expired_borrower = Koha::Patrons->find( $expired_borrowernumber )->unblessed; |
364 |
|
365 |
|
Lines 607-612
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
607 |
is( $error, 'auto_too_soon', |
608 |
is( $error, 'auto_too_soon', |
608 |
'Bug 14101: Cannot renew, renewal is automatic and premature, "No renewal before" = undef (returned code is auto_too_soon)' ); |
609 |
'Bug 14101: Cannot renew, renewal is automatic and premature, "No renewal before" = undef (returned code is auto_too_soon)' ); |
609 |
|
610 |
|
|
|
611 |
$renewing_borrower_obj->autorenewal(0)->store; |
612 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
613 |
is( $renewokay, 1, 'No renewal before is undef, but patron opted out of auto_renewal' ); |
614 |
$renewing_borrower_obj->autorenewal(1)->store; |
615 |
|
616 |
|
610 |
# Bug 7413 |
617 |
# Bug 7413 |
611 |
# Test premature manual renewal |
618 |
# Test premature manual renewal |
612 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 7'); |
619 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 7'); |
Lines 642-647
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
642 |
'Bug 14101: Cannot renew, renewal is automatic and premature (returned code is auto_too_soon)' |
649 |
'Bug 14101: Cannot renew, renewal is automatic and premature (returned code is auto_too_soon)' |
643 |
); |
650 |
); |
644 |
|
651 |
|
|
|
652 |
$renewing_borrower_obj->autorenewal(0)->store; |
653 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
654 |
is( $renewokay, 0, 'No renewal before is 7, patron opted out of auto_renewal still cannot renew early' ); |
655 |
is( $error, 'too_soon', 'Error is too_soon, no auto' ); |
656 |
$renewing_borrower_obj->autorenewal(1)->store; |
657 |
|
645 |
# Change policy so that loans can only be renewed exactly on due date (0 days prior to due date) |
658 |
# Change policy so that loans can only be renewed exactly on due date (0 days prior to due date) |
646 |
# and test automatic renewal again |
659 |
# and test automatic renewal again |
647 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 0'); |
660 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 0'); |
Lines 652-657
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
652 |
'Bug 14101: Cannot renew, renewal is automatic and premature, "No renewal before" = 0 (returned code is auto_too_soon)' |
665 |
'Bug 14101: Cannot renew, renewal is automatic and premature, "No renewal before" = 0 (returned code is auto_too_soon)' |
653 |
); |
666 |
); |
654 |
|
667 |
|
|
|
668 |
$renewing_borrower_obj->autorenewal(0)->store; |
669 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
670 |
is( $renewokay, 0, 'No renewal before is 0, patron opted out of auto_renewal still cannot renew early' ); |
671 |
is( $error, 'too_soon', 'Error is too_soon, no auto' ); |
672 |
$renewing_borrower_obj->autorenewal(1)->store; |
673 |
|
655 |
# Change policy so that loans can be renewed 99 days prior to the due date |
674 |
# Change policy so that loans can be renewed 99 days prior to the due date |
656 |
# and test automatic renewal again |
675 |
# and test automatic renewal again |
657 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 99'); |
676 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 99'); |
Lines 662-667
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
662 |
'Bug 14101: Cannot renew, renewal is automatic (returned code is auto_renew)' |
681 |
'Bug 14101: Cannot renew, renewal is automatic (returned code is auto_renew)' |
663 |
); |
682 |
); |
664 |
|
683 |
|
|
|
684 |
$renewing_borrower_obj->autorenewal(0)->store; |
685 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); |
686 |
is( $renewokay, 1, 'No renewal before is 99, patron opted out of auto_renewal so can renew' ); |
687 |
$renewing_borrower_obj->autorenewal(1)->store; |
688 |
|
665 |
subtest "too_late_renewal / no_auto_renewal_after" => sub { |
689 |
subtest "too_late_renewal / no_auto_renewal_after" => sub { |
666 |
plan tests => 14; |
690 |
plan tests => 14; |
667 |
my $item_to_auto_renew = $builder->build( |
691 |
my $item_to_auto_renew = $builder->build( |
668 |
- |
|
|