Lines 226-232
C4::Context->dbh->do("DELETE FROM borrowers WHERE cardnumber = '99999999999'");
Link Here
|
226 |
C4::Context->dbh->do("DELETE FROM accountlines"); |
226 |
C4::Context->dbh->do("DELETE FROM accountlines"); |
227 |
{ |
227 |
{ |
228 |
# CanBookBeRenewed tests |
228 |
# CanBookBeRenewed tests |
229 |
t::lib::Mocks::mock_preference( 'ItemsDeniedRenewal', '' ); #Ensure pref doesn't affect current tests |
229 |
C4::Context->set_preference('ItemsDeniedRenewal',''); |
230 |
# Generate test biblio |
230 |
# Generate test biblio |
231 |
my $title = 'Silence in the library'; |
231 |
my $title = 'Silence in the library'; |
232 |
my ($biblionumber, $biblioitemnumber) = add_biblio($title, 'Moffat, Steven'); |
232 |
my ($biblionumber, $biblioitemnumber) = add_biblio($title, 'Moffat, Steven'); |
Lines 2214-2220
subtest 'CanBookBeIssued | is_overdue' => sub {
Link Here
|
2214 |
subtest 'ItemsDeniedRenewal preference' => sub { |
2214 |
subtest 'ItemsDeniedRenewal preference' => sub { |
2215 |
plan tests => 18; |
2215 |
plan tests => 18; |
2216 |
|
2216 |
|
2217 |
t::lib::Mocks::mock_preference( 'ItemsDeniedRenewal', '' ); |
2217 |
C4::Context->set_preference('ItemsDeniedRenewal',''); |
2218 |
|
2218 |
|
2219 |
$dbh->do('DELETE FROM issues'); |
2219 |
$dbh->do('DELETE FROM issues'); |
2220 |
$dbh->do('DELETE FROM items'); |
2220 |
$dbh->do('DELETE FROM items'); |
Lines 2279-2285
subtest 'ItemsDeniedRenewal preference' => sub {
Link Here
|
2279 |
|
2279 |
|
2280 |
$idr_rules="withdrawn: [1]"; |
2280 |
$idr_rules="withdrawn: [1]"; |
2281 |
|
2281 |
|
2282 |
t::lib::Mocks::mock_preference( 'ItemsDeniedRenewal', $idr_rules ); |
2282 |
C4::Context->set_preference('ItemsDeniedRenewal',$idr_rules); |
2283 |
( $idr_mayrenew, $idr_error ) = |
2283 |
( $idr_mayrenew, $idr_error ) = |
2284 |
CanBookBeRenewed( $idr_borrower->borrowernumber, $deny_issue->itemnumber ); |
2284 |
CanBookBeRenewed( $idr_borrower->borrowernumber, $deny_issue->itemnumber ); |
2285 |
is( $idr_mayrenew, 0, 'Renewal blocked when 1 rules (withdrawn)' ); |
2285 |
is( $idr_mayrenew, 0, 'Renewal blocked when 1 rules (withdrawn)' ); |
Lines 2291-2297
subtest 'ItemsDeniedRenewal preference' => sub {
Link Here
|
2291 |
|
2291 |
|
2292 |
$idr_rules="withdrawn: [1]\nitype: [HIDE,INVISIBLE]"; |
2292 |
$idr_rules="withdrawn: [1]\nitype: [HIDE,INVISIBLE]"; |
2293 |
|
2293 |
|
2294 |
t::lib::Mocks::mock_preference( 'ItemsDeniedRenewal', $idr_rules ); |
2294 |
C4::Context->set_preference('ItemsDeniedRenewal',$idr_rules); |
2295 |
( $idr_mayrenew, $idr_error ) = |
2295 |
( $idr_mayrenew, $idr_error ) = |
2296 |
CanBookBeRenewed( $idr_borrower->borrowernumber, $deny_issue->itemnumber ); |
2296 |
CanBookBeRenewed( $idr_borrower->borrowernumber, $deny_issue->itemnumber ); |
2297 |
is( $idr_mayrenew, 0, 'Renewal blocked when 2 rules matched (withdrawn, itype)' ); |
2297 |
is( $idr_mayrenew, 0, 'Renewal blocked when 2 rules matched (withdrawn, itype)' ); |
Lines 2303-2309
subtest 'ItemsDeniedRenewal preference' => sub {
Link Here
|
2303 |
|
2303 |
|
2304 |
$idr_rules="withdrawn: [1]\nitype: [HIDE,INVISIBLE]\nlocation: [PROC]"; |
2304 |
$idr_rules="withdrawn: [1]\nitype: [HIDE,INVISIBLE]\nlocation: [PROC]"; |
2305 |
|
2305 |
|
2306 |
t::lib::Mocks::mock_preference( 'ItemsDeniedRenewal', $idr_rules ); |
2306 |
C4::Context->set_preference('ItemsDeniedRenewal',$idr_rules); |
2307 |
( $idr_mayrenew, $idr_error ) = |
2307 |
( $idr_mayrenew, $idr_error ) = |
2308 |
CanBookBeRenewed( $idr_borrower->borrowernumber, $deny_issue->itemnumber ); |
2308 |
CanBookBeRenewed( $idr_borrower->borrowernumber, $deny_issue->itemnumber ); |
2309 |
is( $idr_mayrenew, 0, 'Renewal blocked when 3 rules matched (withdrawn, itype, location)' ); |
2309 |
is( $idr_mayrenew, 0, 'Renewal blocked when 3 rules matched (withdrawn, itype, location)' ); |
Lines 2314-2336
subtest 'ItemsDeniedRenewal preference' => sub {
Link Here
|
2314 |
is( $idr_error, undef, 'Renewal allowed when 3 rules not matched (withdrawn, itype, location)' ); |
2314 |
is( $idr_error, undef, 'Renewal allowed when 3 rules not matched (withdrawn, itype, location)' ); |
2315 |
|
2315 |
|
2316 |
$idr_rules="itemcallnumber: [NULL]"; |
2316 |
$idr_rules="itemcallnumber: [NULL]"; |
2317 |
t::lib::Mocks::mock_preference( 'ItemsDeniedRenewal', $idr_rules ); |
2317 |
C4::Context->set_preference('ItemsDeniedRenewal',$idr_rules); |
2318 |
( $idr_mayrenew, $idr_error ) = |
2318 |
( $idr_mayrenew, $idr_error ) = |
2319 |
CanBookBeRenewed( $idr_borrower->borrowernumber, $deny_issue->itemnumber ); |
2319 |
CanBookBeRenewed( $idr_borrower->borrowernumber, $deny_issue->itemnumber ); |
2320 |
is( $idr_mayrenew, 0, 'Renewal blocked for undef when NULL in pref' ); |
2320 |
is( $idr_mayrenew, 0, 'Renewal blocked for undef when NULL in pref' ); |
2321 |
$idr_rules="itemcallnumber: ['']"; |
2321 |
$idr_rules="itemcallnumber: ['']"; |
2322 |
t::lib::Mocks::mock_preference( 'ItemsDeniedRenewal', $idr_rules ); |
2322 |
C4::Context->set_preference('ItemsDeniedRenewal',$idr_rules); |
2323 |
( $idr_mayrenew, $idr_error ) = |
2323 |
( $idr_mayrenew, $idr_error ) = |
2324 |
CanBookBeRenewed( $idr_borrower->borrowernumber, $deny_issue->itemnumber ); |
2324 |
CanBookBeRenewed( $idr_borrower->borrowernumber, $deny_issue->itemnumber ); |
2325 |
is( $idr_mayrenew, 1, 'Renewal not blocked for undef when "" in pref' ); |
2325 |
is( $idr_mayrenew, 1, 'Renewal not blocked for undef when "" in pref' ); |
2326 |
|
2326 |
|
2327 |
$idr_rules="itemnotes: [NULL]"; |
2327 |
$idr_rules="itemnotes: [NULL]"; |
2328 |
t::lib::Mocks::mock_preference( 'ItemsDeniedRenewal', $idr_rules ); |
2328 |
C4::Context->set_preference('ItemsDeniedRenewal',$idr_rules); |
2329 |
( $idr_mayrenew, $idr_error ) = |
2329 |
( $idr_mayrenew, $idr_error ) = |
2330 |
CanBookBeRenewed( $idr_borrower->borrowernumber, $deny_issue->itemnumber ); |
2330 |
CanBookBeRenewed( $idr_borrower->borrowernumber, $deny_issue->itemnumber ); |
2331 |
is( $idr_mayrenew, 1, 'Renewal not blocked for "" when NULL in pref' ); |
2331 |
is( $idr_mayrenew, 1, 'Renewal not blocked for "" when NULL in pref' ); |
2332 |
$idr_rules="itemnotes: ['']"; |
2332 |
$idr_rules="itemnotes: ['']"; |
2333 |
t::lib::Mocks::mock_preference( 'ItemsDeniedRenewal', $idr_rules ); |
2333 |
C4::Context->set_preference('ItemsDeniedRenewal',$idr_rules); |
2334 |
( $idr_mayrenew, $idr_error ) = |
2334 |
( $idr_mayrenew, $idr_error ) = |
2335 |
CanBookBeRenewed( $idr_borrower->borrowernumber, $deny_issue->itemnumber ); |
2335 |
CanBookBeRenewed( $idr_borrower->borrowernumber, $deny_issue->itemnumber ); |
2336 |
is( $idr_mayrenew, 0, 'Renewal blocked for empty string when "" in pref' ); |
2336 |
is( $idr_mayrenew, 0, 'Renewal blocked for empty string when "" in pref' ); |
Lines 2493-2498
subtest 'AddReturn should clear items.onloan for unissued items' => sub {
Link Here
|
2493 |
}; |
2493 |
}; |
2494 |
|
2494 |
|
2495 |
$schema->storage->txn_rollback; |
2495 |
$schema->storage->txn_rollback; |
|
|
2496 |
C4::Context->clear_syspref_cache(); |
2496 |
$cache->clear_from_cache('single_holidays'); |
2497 |
$cache->clear_from_cache('single_holidays'); |
2497 |
|
2498 |
|
2498 |
sub set_userenv { |
2499 |
sub set_userenv { |