View | Details | Raw Unified | Return to bug 31427
Collapse All | Expand All

(-)a/t/db_dependent/Circulation.t (-2 / +44 lines)
Lines 431-437 subtest "GetIssuingCharges tests" => sub { Link Here
431
431
432
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
432
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
433
subtest "CanBookBeRenewed tests" => sub {
433
subtest "CanBookBeRenewed tests" => sub {
434
    plan tests => 113;
434
    plan tests => 114;
435
435
436
    C4::Context->set_preference('ItemsDeniedRenewal','');
436
    C4::Context->set_preference('ItemsDeniedRenewal','');
437
    # Generate test biblio
437
    # Generate test biblio
Lines 1011-1016 subtest "CanBookBeRenewed tests" => sub { Link Here
1011
    is( $renewokay, 1, 'No renewal before is 99, patron opted out of auto_renewal so can renew' );
1011
    is( $renewokay, 1, 'No renewal before is 99, patron opted out of auto_renewal so can renew' );
1012
    $renewing_borrower_obj->autorenew_checkouts(1)->store;
1012
    $renewing_borrower_obj->autorenew_checkouts(1)->store;
1013
1013
1014
1015
    # Bug 31427
1016
    # Ensure autorenewal errors always take highest precedence
1017
    subtest "auto_renewal errors first" => sub {
1018
        plan tests => 4;
1019
1020
        my $auto_renew_item = $builder->build_sample_item(
1021
            {
1022
                biblionumber => $biblio->biblionumber,
1023
                library      => $branch,
1024
            }
1025
        );
1026
1027
        my $ten_days_ahead = dt_from_string->add( days => 10 );
1028
        my $issue          = AddIssue(
1029
            $renewing_borrower_obj, $auto_renew_item->barcode, $ten_days_ahead, undef, undef, undef,
1030
            { auto_renew => 1 }
1031
        );
1032
1033
        Koha::CirculationRules->set_rules(
1034
            {
1035
                categorycode => undef,
1036
                branchcode   => undef,
1037
                itemtype     => undef,
1038
                rules        => {
1039
                    noautorenewalbefore => 7,
1040
                    renewalsallowed     => 2,
1041
                }
1042
            }
1043
        );
1044
        my ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue, undef, 'cron' );
1045
        is( $renewokay, 0,               'Do not renew, renewal is automatic' );
1046
        is( $error,     'auto_too_soon', 'Cannot auto renew, too soon - returned code is auto_too_soon' );
1047
1048
        $issue->renewals_count(2)->store;
1049
        ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue, undef, 'cron' );
1050
        is( $renewokay, 0, 'Do not renew, renewal is automatic' );
1051
        is(
1052
            $error, 'auto_too_soon',
1053
            'Cannot auto renew, too soon - auto renewal error takes precedence over non-autorenewal error too_many'
1054
        );
1055
    };
1056
1014
    subtest "too_late_renewal / no_auto_renewal_after" => sub {
1057
    subtest "too_late_renewal / no_auto_renewal_after" => sub {
1015
        plan tests => 16;
1058
        plan tests => 16;
1016
        my $item_to_auto_renew = $builder->build_sample_item(
1059
        my $item_to_auto_renew = $builder->build_sample_item(
1017
- 

Return to bug 31427