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

(-)a/t/db_dependent/Circulation.t (-9 / +9 lines)
Lines 157-163 my $patron_category = $builder->build( Link Here
157
        value  => {
157
        value  => {
158
            category_type                 => 'P',
158
            category_type                 => 'P',
159
            enrolmentfee                  => 0,
159
            enrolmentfee                  => 0,
160
            BlockExpiredPatronOpacActions => -1, # Pick the pref value
160
            BlockExpiredPatronOpacActions => 'follow_syspref_BlockExpiredPatronOpacActions',
161
        }
161
        }
162
    }
162
    }
163
);
163
);
Lines 1340-1359 subtest "CanBookBeRenewed tests" => sub { Link Here
1340
        my $ten_days_before = dt_from_string->add( days => -10 );
1340
        my $ten_days_before = dt_from_string->add( days => -10 );
1341
        my $ten_days_ahead = dt_from_string->add( days => 10 );
1341
        my $ten_days_ahead = dt_from_string->add( days => 10 );
1342
1342
1343
        # Patron is expired and BlockExpiredPatronOpacActions=0
1343
        # Patron is expired and BlockExpiredPatronOpacActions=''
1344
        # => auto renew is allowed
1344
        # => auto renew is allowed
1345
        t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 0);
1345
        t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', '');
1346
        my $issue = AddIssue( $expired_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } );
1346
        my $issue = AddIssue( $expired_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } );
1347
        ( $renewokay, $error ) =
1347
        ( $renewokay, $error ) =
1348
          CanBookBeRenewed( $expired_borrower_obj, $issue );
1348
          CanBookBeRenewed( $expired_borrower_obj, $issue );
1349
        is( $renewokay, 1, 'Renew, even if renewal is automatic' );
1349
        is( $renewokay, 1, 'Renew, even if renewal is automatic' );
1350
        is( $error, 'auto_renew', 'Can auto renew, patron is expired but BlockExpiredPatronOpacActions=0' );
1350
        is( $error, 'auto_renew', 'Can auto renew, patron is expired but BlockExpiredPatronOpacActions=\'\'' );
1351
        Koha::Checkouts->find( $issue->issue_id )->delete;
1351
        Koha::Checkouts->find( $issue->issue_id )->delete;
1352
1352
1353
1353
1354
        # Patron is expired and BlockExpiredPatronOpacActions=1
1354
        # Patron is expired and BlockExpiredPatronOpacActions='renew'
1355
        # => auto renew is not allowed
1355
        # => auto renew is not allowed
1356
        t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 1);
1356
        t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 'renew');
1357
        $issue = AddIssue( $expired_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } );
1357
        $issue = AddIssue( $expired_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } );
1358
        ( $renewokay, $error ) =
1358
        ( $renewokay, $error ) =
1359
          CanBookBeRenewed( $expired_borrower_obj, $issue );
1359
          CanBookBeRenewed( $expired_borrower_obj, $issue );
Lines 1363-1374 subtest "CanBookBeRenewed tests" => sub { Link Here
1363
1363
1364
        # Patron is not expired and BlockExpiredPatronOpacActions=1
1364
        # Patron is not expired and BlockExpiredPatronOpacActions=1
1365
        # => auto renew is allowed
1365
        # => auto renew is allowed
1366
        t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 1);
1366
        t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 'renew');
1367
        $issue = AddIssue( $renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } );
1367
        $issue = AddIssue( $renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } );
1368
        ( $renewokay, $error ) =
1368
        ( $renewokay, $error ) =
1369
          CanBookBeRenewed( $renewing_borrower_obj, $issue );
1369
          CanBookBeRenewed( $renewing_borrower_obj, $issue );
1370
        is( $renewokay, 1, 'Renew, even if renewal is automatic' );
1370
        is( $renewokay, 1, 'Renew, even if renewal is automatic' );
1371
        is( $error, 'auto_renew', 'Can auto renew, BlockExpiredPatronOpacActions=1 but patron is not expired' );
1371
        is( $error, 'auto_renew', 'Can auto renew, BlockExpiredPatronOpacActions=\'renew\' but patron is not expired' );
1372
        $issue->delete;
1372
        $issue->delete;
1373
    };
1373
    };
1374
1374
Lines 1983-1989 subtest "AllowRenewalIfOtherItemsAvailable tests" => sub { Link Here
1983
            value  => {
1983
            value  => {
1984
                category_type                 => 'P',
1984
                category_type                 => 'P',
1985
                enrolmentfee                  => 0,
1985
                enrolmentfee                  => 0,
1986
                BlockExpiredPatronOpacActions => -1, # Pick the pref value
1986
                BlockExpiredPatronOpacActions => 'follow_syspref_BlockExpiredPatronOpacActions',
1987
            }
1987
            }
1988
        }
1988
        }
1989
    );
1989
    );
(-)a/t/db_dependent/ILSDI_Services.t (-3 / +3 lines)
Lines 274-280 subtest 'GetPatronInfo/GetBorrowerAttributes test for extended patron attributes Link Here
274
        source => 'Category',
274
        source => 'Category',
275
        value  => {
275
        value  => {
276
            category_type                 => 'A',
276
            category_type                 => 'A',
277
            BlockExpiredPatronOpacActions => -1,
277
            BlockExpiredPatronOpacActions => 'follow_syspref_BlockExpiredPatronOpacActions',
278
        }
278
        }
279
    } );
279
    } );
280
280
Lines 584-590 subtest 'Holds test' => sub { Link Here
584
    # Test Patron cannot reserve if expired and BlockExpiredPatronOpacActions
584
    # Test Patron cannot reserve if expired and BlockExpiredPatronOpacActions
585
    my $category = $builder->build({
585
    my $category = $builder->build({
586
        source => 'Category',
586
        source => 'Category',
587
        value => { BlockExpiredPatronOpacActions => -1 }
587
        value => { BlockExpiredPatronOpacActions => 'follow_syspref_BlockExpiredPatronOpacActions' }
588
        });
588
        });
589
589
590
    my $branch_1 = $builder->build({ source => 'Branch' })->{ branchcode };
590
    my $branch_1 = $builder->build({ source => 'Branch' })->{ branchcode };
Lines 597-603 subtest 'Holds test' => sub { Link Here
597
        dateexpiry => '2000-01-01',
597
        dateexpiry => '2000-01-01',
598
    })->store->borrowernumber;
598
    })->store->borrowernumber;
599
599
600
    t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 1);
600
    t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 'hold,renew');
601
601
602
    my $item5 = $builder->build({
602
    my $item5 = $builder->build({
603
        source => 'Item',
603
        source => 'Item',
(-)a/t/db_dependent/Koha/Object.t (-1 / +1 lines)
Lines 1049-1055 subtest 'unblessed_all_relateds' => sub { Link Here
1049
            value  => {
1049
            value  => {
1050
                category_type                 => 'P',
1050
                category_type                 => 'P',
1051
                enrolmentfee                  => 0,
1051
                enrolmentfee                  => 0,
1052
                BlockExpiredPatronOpacActions => -1, # Pick the pref value
1052
                BlockExpiredPatronOpacActions => 'follow_syspref_BlockExpiredPatronOpacActions',
1053
            }
1053
            }
1054
        }
1054
        }
1055
    );
1055
    );
(-)a/t/db_dependent/Koha/Patron/Categories.t (-7 / +7 lines)
Lines 103-120 subtest 'get_expiry_date' => sub { Link Here
103
};
103
};
104
104
105
subtest 'BlockExpiredPatronOpacActions' => sub {
105
subtest 'BlockExpiredPatronOpacActions' => sub {
106
    plan tests => 2;
106
    plan tests => 3;
107
    t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 42);
107
    t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 'hold');
108
    my $category = Koha::Patron::Category->new({
108
    my $category = Koha::Patron::Category->new({
109
        categorycode => 'ya_cat',
109
        categorycode => 'ya_cat',
110
        category_type => 'A',
110
        category_type => 'A',
111
        description  => 'yacatdesc',
111
        description  => 'yacatdesc',
112
        enrolmentperiod => undef,
112
        enrolmentperiod => undef,
113
        BlockExpiredPatronOpacActions => -1,
113
        BlockExpiredPatronOpacActions => 'follow_syspref_BlockExpiredPatronOpacActions',
114
    })->store;
114
    })->store;
115
    is( $category->effective_BlockExpiredPatronOpacActions, 42 );
115
    is( $category->effective_BlockExpiredPatronOpacActions_contains('hold'), 1 );
116
    $category->BlockExpiredPatronOpacActions(24)->store;
116
    is( $category->effective_BlockExpiredPatronOpacActions_contains('renew'), undef );
117
    is( $category->effective_BlockExpiredPatronOpacActions, 24 );
117
    $category->BlockExpiredPatronOpacActions('renew')->store;
118
    is( $category->effective_BlockExpiredPatronOpacActions_contains('renew'), 1 );
118
    $category->delete;
119
    $category->delete;
119
};
120
};
120
121
121
- 

Return to bug 36453