Bug 36453: Update tests
Address new new version of system pref Address new version of categories DB table BlockExpiredPatronOpacActions column Test plan, k-t-d, BEFORE applying patch: 1) Edit some patron categories, visit: /cgi-bin/koha/admin/categories.pl 2) Set different values for the "Block expired patrons" input config Set a category to block Set a category to don't block Set a category to follow the syspref 3) Take note of the current value of the BlockExpiredPatronOpacActions sys pref Apply patch, then run the following commands - koha-plack --restart kohadev - yarn css:build - run updatedatabase 4) Visit the patron categories you edited before, make sure they all have the correct values for the new config type 5) Check the BlockExpiredPatronOpacActions sys pref and make sure the new value is correct according to what was before 6) Add a new patron of one of the above categories, test that: If 'hold' is a blocked action, patron is unable to place a hold in OPAC If 'renew' is a blocked action, patron is unable to renew in OPAC If 'follow sys pref' is the option, check that a patron may place a hold or renew an item according to the BlockExpiredPatronOpacActions sys pref value prove t/db_dependent/Circulation.t prove t/db_dependent/ILSDI_Services.t prove t/db_dependent/Koha/Object.t prove t/db_dependent/Koha/Patron/Categories.t Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
parent
9036b0a417
commit
51da2b5dad
4 changed files with 20 additions and 19 deletions
|
@ -157,7 +157,7 @@ my $patron_category = $builder->build(
|
|||
value => {
|
||||
category_type => 'P',
|
||||
enrolmentfee => 0,
|
||||
BlockExpiredPatronOpacActions => -1, # Pick the pref value
|
||||
BlockExpiredPatronOpacActions => 'follow_syspref_BlockExpiredPatronOpacActions',
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -1340,20 +1340,20 @@ subtest "CanBookBeRenewed tests" => sub {
|
|||
my $ten_days_before = dt_from_string->add( days => -10 );
|
||||
my $ten_days_ahead = dt_from_string->add( days => 10 );
|
||||
|
||||
# Patron is expired and BlockExpiredPatronOpacActions=0
|
||||
# Patron is expired and BlockExpiredPatronOpacActions=''
|
||||
# => auto renew is allowed
|
||||
t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 0);
|
||||
t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', '');
|
||||
my $issue = AddIssue( $expired_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } );
|
||||
( $renewokay, $error ) =
|
||||
CanBookBeRenewed( $expired_borrower_obj, $issue );
|
||||
is( $renewokay, 1, 'Renew, even if renewal is automatic' );
|
||||
is( $error, 'auto_renew', 'Can auto renew, patron is expired but BlockExpiredPatronOpacActions=0' );
|
||||
is( $error, 'auto_renew', 'Can auto renew, patron is expired but BlockExpiredPatronOpacActions=\'\'' );
|
||||
Koha::Checkouts->find( $issue->issue_id )->delete;
|
||||
|
||||
|
||||
# Patron is expired and BlockExpiredPatronOpacActions=1
|
||||
# Patron is expired and BlockExpiredPatronOpacActions='renew'
|
||||
# => auto renew is not allowed
|
||||
t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 1);
|
||||
t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 'renew');
|
||||
$issue = AddIssue( $expired_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } );
|
||||
( $renewokay, $error ) =
|
||||
CanBookBeRenewed( $expired_borrower_obj, $issue );
|
||||
|
@ -1363,12 +1363,12 @@ subtest "CanBookBeRenewed tests" => sub {
|
|||
|
||||
# Patron is not expired and BlockExpiredPatronOpacActions=1
|
||||
# => auto renew is allowed
|
||||
t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 1);
|
||||
t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 'renew');
|
||||
$issue = AddIssue( $renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } );
|
||||
( $renewokay, $error ) =
|
||||
CanBookBeRenewed( $renewing_borrower_obj, $issue );
|
||||
is( $renewokay, 1, 'Renew, even if renewal is automatic' );
|
||||
is( $error, 'auto_renew', 'Can auto renew, BlockExpiredPatronOpacActions=1 but patron is not expired' );
|
||||
is( $error, 'auto_renew', 'Can auto renew, BlockExpiredPatronOpacActions=\'renew\' but patron is not expired' );
|
||||
$issue->delete;
|
||||
};
|
||||
|
||||
|
@ -1983,7 +1983,7 @@ subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
|
|||
value => {
|
||||
category_type => 'P',
|
||||
enrolmentfee => 0,
|
||||
BlockExpiredPatronOpacActions => -1, # Pick the pref value
|
||||
BlockExpiredPatronOpacActions => 'follow_syspref_BlockExpiredPatronOpacActions',
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
|
@ -274,7 +274,7 @@ subtest 'GetPatronInfo/GetBorrowerAttributes test for extended patron attributes
|
|||
source => 'Category',
|
||||
value => {
|
||||
category_type => 'A',
|
||||
BlockExpiredPatronOpacActions => -1,
|
||||
BlockExpiredPatronOpacActions => 'follow_syspref_BlockExpiredPatronOpacActions',
|
||||
}
|
||||
} );
|
||||
|
||||
|
@ -584,7 +584,7 @@ subtest 'Holds test' => sub {
|
|||
# Test Patron cannot reserve if expired and BlockExpiredPatronOpacActions
|
||||
my $category = $builder->build({
|
||||
source => 'Category',
|
||||
value => { BlockExpiredPatronOpacActions => -1 }
|
||||
value => { BlockExpiredPatronOpacActions => 'follow_syspref_BlockExpiredPatronOpacActions' }
|
||||
});
|
||||
|
||||
my $branch_1 = $builder->build({ source => 'Branch' })->{ branchcode };
|
||||
|
@ -597,7 +597,7 @@ subtest 'Holds test' => sub {
|
|||
dateexpiry => '2000-01-01',
|
||||
})->store->borrowernumber;
|
||||
|
||||
t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 1);
|
||||
t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 'hold,renew');
|
||||
|
||||
my $item5 = $builder->build({
|
||||
source => 'Item',
|
||||
|
|
|
@ -1049,7 +1049,7 @@ subtest 'unblessed_all_relateds' => sub {
|
|||
value => {
|
||||
category_type => 'P',
|
||||
enrolmentfee => 0,
|
||||
BlockExpiredPatronOpacActions => -1, # Pick the pref value
|
||||
BlockExpiredPatronOpacActions => 'follow_syspref_BlockExpiredPatronOpacActions',
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
|
@ -103,18 +103,19 @@ subtest 'get_expiry_date' => sub {
|
|||
};
|
||||
|
||||
subtest 'BlockExpiredPatronOpacActions' => sub {
|
||||
plan tests => 2;
|
||||
t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 42);
|
||||
plan tests => 3;
|
||||
t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 'hold');
|
||||
my $category = Koha::Patron::Category->new({
|
||||
categorycode => 'ya_cat',
|
||||
category_type => 'A',
|
||||
description => 'yacatdesc',
|
||||
enrolmentperiod => undef,
|
||||
BlockExpiredPatronOpacActions => -1,
|
||||
BlockExpiredPatronOpacActions => 'follow_syspref_BlockExpiredPatronOpacActions',
|
||||
})->store;
|
||||
is( $category->effective_BlockExpiredPatronOpacActions, 42 );
|
||||
$category->BlockExpiredPatronOpacActions(24)->store;
|
||||
is( $category->effective_BlockExpiredPatronOpacActions, 24 );
|
||||
is( $category->effective_BlockExpiredPatronOpacActions_contains('hold'), 1 );
|
||||
is( $category->effective_BlockExpiredPatronOpacActions_contains('renew'), undef );
|
||||
$category->BlockExpiredPatronOpacActions('renew')->store;
|
||||
is( $category->effective_BlockExpiredPatronOpacActions_contains('renew'), 1 );
|
||||
$category->delete;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue