|
Lines 430-436
subtest "GetIssuingCharges tests" => sub {
Link Here
|
| 430 |
|
430 |
|
| 431 |
my ( $reused_itemnumber_1, $reused_itemnumber_2 ); |
431 |
my ( $reused_itemnumber_1, $reused_itemnumber_2 ); |
| 432 |
subtest "CanBookBeRenewed tests" => sub { |
432 |
subtest "CanBookBeRenewed tests" => sub { |
| 433 |
plan tests => 104; |
433 |
plan tests => 105; |
| 434 |
|
434 |
|
| 435 |
C4::Context->set_preference('ItemsDeniedRenewal',''); |
435 |
C4::Context->set_preference('ItemsDeniedRenewal',''); |
| 436 |
# Generate test biblio |
436 |
# Generate test biblio |
|
Lines 1345-1352
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
| 1345 |
); |
1345 |
); |
| 1346 |
|
1346 |
|
| 1347 |
}; |
1347 |
}; |
| 1348 |
# Too many renewals |
|
|
| 1349 |
|
1348 |
|
|
|
1349 |
subtest "auto_renew_final" => sub { |
| 1350 |
plan tests => 6; |
| 1351 |
my $item_to_auto_renew = $builder->build_sample_item(); |
| 1352 |
Koha::CirculationRules->set_rules( |
| 1353 |
{ |
| 1354 |
categorycode => undef, |
| 1355 |
branchcode => undef, |
| 1356 |
itemtype => $item_to_auto_renew->itype, |
| 1357 |
rules => { |
| 1358 |
norenewalbefore => undef, |
| 1359 |
renewalsallowed => 1, |
| 1360 |
} |
| 1361 |
} |
| 1362 |
); |
| 1363 |
|
| 1364 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
| 1365 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
| 1366 |
my $issue = AddIssue( |
| 1367 |
$renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, |
| 1368 |
undef, { auto_renew => 1 } |
| 1369 |
); |
| 1370 |
$issue->renewals_count(0)->store; |
| 1371 |
|
| 1372 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue ); |
| 1373 |
is( $renewokay, 0, 'No success for auto_renewal' ); |
| 1374 |
is( $error, 'auto_renew_final', 'Auto renewal allowed, but it is the last one' ); |
| 1375 |
|
| 1376 |
# Final unseen renewal |
| 1377 |
Koha::CirculationRules->set_rules( |
| 1378 |
{ |
| 1379 |
categorycode => undef, |
| 1380 |
branchcode => undef, |
| 1381 |
itemtype => $item_to_auto_renew->itype, |
| 1382 |
rules => { |
| 1383 |
unseen_renewals_allowed => 2, |
| 1384 |
renewalsallowed => 10, |
| 1385 |
} |
| 1386 |
} |
| 1387 |
); |
| 1388 |
t::lib::Mocks::mock_preference( 'UnseenRenewals', 1 ); |
| 1389 |
$issue->unseen_renewals(1)->renewals_count(1)->store; |
| 1390 |
|
| 1391 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue ); |
| 1392 |
is( $renewokay, 0, 'No success for auto_renewal' ); |
| 1393 |
is( $error, 'auto_unseen_final', 'Final unseen renewal reported, not final overall' ); |
| 1394 |
|
| 1395 |
# Final unseen renewal |
| 1396 |
Koha::CirculationRules->set_rules( |
| 1397 |
{ |
| 1398 |
categorycode => undef, |
| 1399 |
branchcode => undef, |
| 1400 |
itemtype => $item_to_auto_renew->itype, |
| 1401 |
rules => { |
| 1402 |
unseen_renewals_allowed => 2, |
| 1403 |
renewalsallowed => 2, |
| 1404 |
} |
| 1405 |
} |
| 1406 |
); |
| 1407 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue ); |
| 1408 |
is( $renewokay, 0, 'No success for auto_renewal' ); |
| 1409 |
is( $error, 'auto_renew_final', 'Final auto renewal reported' ); |
| 1410 |
|
| 1411 |
}; |
| 1412 |
|
| 1413 |
# Too many renewals |
| 1350 |
# set policy to forbid renewals |
1414 |
# set policy to forbid renewals |
| 1351 |
Koha::CirculationRules->set_rules( |
1415 |
Koha::CirculationRules->set_rules( |
| 1352 |
{ |
1416 |
{ |
|
Lines 1377-1382
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
| 1377 |
} |
1441 |
} |
| 1378 |
); |
1442 |
); |
| 1379 |
t::lib::Mocks::mock_preference('UnseenRenewals', 1); |
1443 |
t::lib::Mocks::mock_preference('UnseenRenewals', 1); |
|
|
1444 |
|
| 1380 |
$issue_1->unseen_renewals(2)->store; |
1445 |
$issue_1->unseen_renewals(2)->store; |
| 1381 |
|
1446 |
|
| 1382 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrower_obj, $issue_1); |
1447 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrower_obj, $issue_1); |
| 1383 |
- |
|
|