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 1321-1340 subtest "CanBookBeRenewed tests" => sub { Link Here
1321
        my $ten_days_before = dt_from_string->add( days => -10 );
1321
        my $ten_days_before = dt_from_string->add( days => -10 );
1322
        my $ten_days_ahead = dt_from_string->add( days => 10 );
1322
        my $ten_days_ahead = dt_from_string->add( days => 10 );
1323
1323
1324
        # Patron is expired and BlockExpiredPatronOpacActions=0
1324
        # Patron is expired and BlockExpiredPatronOpacActions=''
1325
        # => auto renew is allowed
1325
        # => auto renew is allowed
1326
        t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 0);
1326
        t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', '');
1327
        my $issue = AddIssue( $expired_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } );
1327
        my $issue = AddIssue( $expired_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } );
1328
        ( $renewokay, $error ) =
1328
        ( $renewokay, $error ) =
1329
          CanBookBeRenewed( $expired_borrower_obj, $issue );
1329
          CanBookBeRenewed( $expired_borrower_obj, $issue );
1330
        is( $renewokay, 1, 'Renew, even if renewal is automatic' );
1330
        is( $renewokay, 1, 'Renew, even if renewal is automatic' );
1331
        is( $error, 'auto_renew', 'Can auto renew, patron is expired but BlockExpiredPatronOpacActions=0' );
1331
        is( $error, 'auto_renew', 'Can auto renew, patron is expired but BlockExpiredPatronOpacActions=\'\'' );
1332
        Koha::Checkouts->find( $issue->issue_id )->delete;
1332
        Koha::Checkouts->find( $issue->issue_id )->delete;
1333
1333
1334
1334
1335
        # Patron is expired and BlockExpiredPatronOpacActions=1
1335
        # Patron is expired and BlockExpiredPatronOpacActions='renew'
1336
        # => auto renew is not allowed
1336
        # => auto renew is not allowed
1337
        t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 1);
1337
        t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 'renew');
1338
        $issue = AddIssue( $expired_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } );
1338
        $issue = AddIssue( $expired_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } );
1339
        ( $renewokay, $error ) =
1339
        ( $renewokay, $error ) =
1340
          CanBookBeRenewed( $expired_borrower_obj, $issue );
1340
          CanBookBeRenewed( $expired_borrower_obj, $issue );
Lines 1344-1355 subtest "CanBookBeRenewed tests" => sub { Link Here
1344
1344
1345
        # Patron is not expired and BlockExpiredPatronOpacActions=1
1345
        # Patron is not expired and BlockExpiredPatronOpacActions=1
1346
        # => auto renew is allowed
1346
        # => auto renew is allowed
1347
        t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 1);
1347
        t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 'renew');
1348
        $issue = AddIssue( $renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } );
1348
        $issue = AddIssue( $renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } );
1349
        ( $renewokay, $error ) =
1349
        ( $renewokay, $error ) =
1350
          CanBookBeRenewed( $renewing_borrower_obj, $issue );
1350
          CanBookBeRenewed( $renewing_borrower_obj, $issue );
1351
        is( $renewokay, 1, 'Renew, even if renewal is automatic' );
1351
        is( $renewokay, 1, 'Renew, even if renewal is automatic' );
1352
        is( $error, 'auto_renew', 'Can auto renew, BlockExpiredPatronOpacActions=1 but patron is not expired' );
1352
        is( $error, 'auto_renew', 'Can auto renew, BlockExpiredPatronOpacActions=\'renew\' but patron is not expired' );
1353
        $issue->delete;
1353
        $issue->delete;
1354
    };
1354
    };
1355
1355
Lines 1950-1956 subtest "AllowRenewalIfOtherItemsAvailable tests" => sub { Link Here
1950
            value  => {
1950
            value  => {
1951
                category_type                 => 'P',
1951
                category_type                 => 'P',
1952
                enrolmentfee                  => 0,
1952
                enrolmentfee                  => 0,
1953
                BlockExpiredPatronOpacActions => -1, # Pick the pref value
1953
                BlockExpiredPatronOpacActions => 'follow_syspref_BlockExpiredPatronOpacActions',
1954
            }
1954
            }
1955
        }
1955
        }
1956
    );
1956
    );
(-)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 1041-1047 subtest 'unblessed_all_relateds' => sub { Link Here
1041
            value  => {
1041
            value  => {
1042
                category_type                 => 'P',
1042
                category_type                 => 'P',
1043
                enrolmentfee                  => 0,
1043
                enrolmentfee                  => 0,
1044
                BlockExpiredPatronOpacActions => -1, # Pick the pref value
1044
                BlockExpiredPatronOpacActions => 'follow_syspref_BlockExpiredPatronOpacActions',
1045
            }
1045
            }
1046
        }
1046
        }
1047
    );
1047
    );
(-)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