Lines 18-24
Link Here
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
use utf8; |
19 |
use utf8; |
20 |
|
20 |
|
21 |
use Test::More tests => 130; |
21 |
use Test::More tests => 44; |
22 |
use Test::MockModule; |
22 |
use Test::MockModule; |
23 |
|
23 |
|
24 |
use Data::Dumper; |
24 |
use Data::Dumper; |
Lines 276-283
$dbh->do(
Link Here
|
276 |
); |
276 |
); |
277 |
|
277 |
|
278 |
my ( $reused_itemnumber_1, $reused_itemnumber_2 ); |
278 |
my ( $reused_itemnumber_1, $reused_itemnumber_2 ); |
279 |
{ |
279 |
subtest "CanBookBeRenewed tests" => sub { |
280 |
# CanBookBeRenewed tests |
280 |
plan tests => 71; |
|
|
281 |
|
281 |
C4::Context->set_preference('ItemsDeniedRenewal',''); |
282 |
C4::Context->set_preference('ItemsDeniedRenewal',''); |
282 |
# Generate test biblio |
283 |
# Generate test biblio |
283 |
my $biblio = $builder->build_sample_biblio(); |
284 |
my $biblio = $builder->build_sample_biblio(); |
Lines 560-566
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
Link Here
|
560 |
is ($new_log_size, $old_log_size + 1, 'renew log successfully added'); |
561 |
is ($new_log_size, $old_log_size + 1, 'renew log successfully added'); |
561 |
|
562 |
|
562 |
my $fines = Koha::Account::Lines->search( { borrowernumber => $renewing_borrower->{borrowernumber}, itemnumber => $item_7->itemnumber } ); |
563 |
my $fines = Koha::Account::Lines->search( { borrowernumber => $renewing_borrower->{borrowernumber}, itemnumber => $item_7->itemnumber } ); |
563 |
is( $fines->count, 2 ); |
564 |
is( $fines->count, 2, 'AddRenewal left both fines' ); |
564 |
isnt( $fines->next->status, 'UNRETURNED', 'Fine on renewed item is closed out properly' ); |
565 |
isnt( $fines->next->status, 'UNRETURNED', 'Fine on renewed item is closed out properly' ); |
565 |
isnt( $fines->next->status, 'UNRETURNED', 'Fine on renewed item is closed out properly' ); |
566 |
isnt( $fines->next->status, 'UNRETURNED', 'Fine on renewed item is closed out properly' ); |
566 |
$fines->delete(); |
567 |
$fines->delete(); |
Lines 994-1003
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
Link Here
|
994 |
$item_3->itemcallnumber || '' ), |
995 |
$item_3->itemcallnumber || '' ), |
995 |
"Account line description must not contain 'Lost Items ', but be title, barcode, itemcallnumber" |
996 |
"Account line description must not contain 'Lost Items ', but be title, barcode, itemcallnumber" |
996 |
); |
997 |
); |
997 |
} |
998 |
}; |
|
|
999 |
|
1000 |
subtest "GetUpcomingDueIssues" => sub { |
1001 |
plan tests => 12; |
998 |
|
1002 |
|
999 |
{ |
|
|
1000 |
# GetUpcomingDueIssues tests |
1001 |
my $branch = $library2->{branchcode}; |
1003 |
my $branch = $library2->{branchcode}; |
1002 |
|
1004 |
|
1003 |
#Create another record |
1005 |
#Create another record |
Lines 1075-1083
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
Link Here
|
1075 |
$upcoming_dues = C4::Circulation::GetUpcomingDueIssues(); |
1077 |
$upcoming_dues = C4::Circulation::GetUpcomingDueIssues(); |
1076 |
is ( scalar ( @$upcoming_dues), 2, "days_in_advance is 7 in GetUpcomingDueIssues if not provided" ); |
1078 |
is ( scalar ( @$upcoming_dues), 2, "days_in_advance is 7 in GetUpcomingDueIssues if not provided" ); |
1077 |
|
1079 |
|
1078 |
} |
1080 |
}; |
1079 |
|
1081 |
|
1080 |
{ |
1082 |
subtest "Bug 13841 - Do not create new 0 amount fines" => sub { |
1081 |
my $branch = $library2->{branchcode}; |
1083 |
my $branch = $library2->{branchcode}; |
1082 |
|
1084 |
|
1083 |
my $biblio = $builder->build_sample_biblio(); |
1085 |
my $biblio = $builder->build_sample_biblio(); |
Lines 1117-1125
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
Link Here
|
1117 |
my $count = $hr->{count}; |
1119 |
my $count = $hr->{count}; |
1118 |
|
1120 |
|
1119 |
is ( $count, 0, "Calling UpdateFine on non-existant fine with an amount of 0 does not result in an empty fine" ); |
1121 |
is ( $count, 0, "Calling UpdateFine on non-existant fine with an amount of 0 does not result in an empty fine" ); |
1120 |
} |
1122 |
}; |
1121 |
|
1123 |
|
1122 |
{ |
1124 |
subtest "AllowRenewalIfOtherItemsAvailable tests" => sub { |
1123 |
$dbh->do('DELETE FROM issues'); |
1125 |
$dbh->do('DELETE FROM issues'); |
1124 |
$dbh->do('DELETE FROM items'); |
1126 |
$dbh->do('DELETE FROM items'); |
1125 |
$dbh->do('DELETE FROM issuingrules'); |
1127 |
$dbh->do('DELETE FROM issuingrules'); |
Lines 1216-1222
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
Link Here
|
1216 |
|
1218 |
|
1217 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber ); |
1219 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber ); |
1218 |
is( $renewokay, 0, 'Bug 14337 - Verify the borrower can not renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is enabled but the only available item is notforloan' ); |
1220 |
is( $renewokay, 0, 'Bug 14337 - Verify the borrower can not renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is enabled but the only available item is notforloan' ); |
1219 |
} |
1221 |
}; |
1220 |
|
1222 |
|
1221 |
{ |
1223 |
{ |
1222 |
# Don't allow renewing onsite checkout |
1224 |
# Don't allow renewing onsite checkout |
Lines 1340-1346
subtest 'CanBookBeIssued & AllowReturnToBranch' => sub {
Link Here
|
1340 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
1342 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
1341 |
is( keys(%$question) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
1343 |
is( keys(%$question) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
1342 |
is( exists $error->{RETURN_IMPOSSIBLE}, 1, 'RETURN_IMPOSSIBLE must be set' ); |
1344 |
is( exists $error->{RETURN_IMPOSSIBLE}, 1, 'RETURN_IMPOSSIBLE must be set' ); |
1343 |
is( $error->{branch_to_return}, $holdingbranch->{branchcode} ); |
1345 |
is( $error->{branch_to_return}, $holdingbranch->{branchcode}, 'branch_to_return matched holdingbranch' ); |
1344 |
## Can be issued from holdinbranch |
1346 |
## Can be issued from holdinbranch |
1345 |
set_userenv($holdingbranch); |
1347 |
set_userenv($holdingbranch); |
1346 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
1348 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
Lines 1351-1357
subtest 'CanBookBeIssued & AllowReturnToBranch' => sub {
Link Here
|
1351 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
1353 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
1352 |
is( keys(%$question) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
1354 |
is( keys(%$question) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
1353 |
is( exists $error->{RETURN_IMPOSSIBLE}, 1, 'RETURN_IMPOSSIBLE must be set' ); |
1355 |
is( exists $error->{RETURN_IMPOSSIBLE}, 1, 'RETURN_IMPOSSIBLE must be set' ); |
1354 |
is( $error->{branch_to_return}, $holdingbranch->{branchcode} ); |
1356 |
is( $error->{branch_to_return}, $holdingbranch->{branchcode}, 'branch_to_return matches holdingbranch' ); |
1355 |
|
1357 |
|
1356 |
# AllowReturnToBranch == homebranch |
1358 |
# AllowReturnToBranch == homebranch |
1357 |
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'homebranch' ); |
1359 |
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'homebranch' ); |
Lines 1365-1377
subtest 'CanBookBeIssued & AllowReturnToBranch' => sub {
Link Here
|
1365 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
1367 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
1366 |
is( keys(%$question) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
1368 |
is( keys(%$question) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
1367 |
is( exists $error->{RETURN_IMPOSSIBLE}, 1, 'RETURN_IMPOSSIBLE must be set' ); |
1369 |
is( exists $error->{RETURN_IMPOSSIBLE}, 1, 'RETURN_IMPOSSIBLE must be set' ); |
1368 |
is( $error->{branch_to_return}, $homebranch->{branchcode} ); |
1370 |
is( $error->{branch_to_return}, $homebranch->{branchcode}, 'branch_to_return matches homebranch' ); |
1369 |
## Cannot be issued from holdinbranch |
1371 |
## Cannot be issued from holdinbranch |
1370 |
set_userenv($otherbranch); |
1372 |
set_userenv($otherbranch); |
1371 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
1373 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
1372 |
is( keys(%$question) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
1374 |
is( keys(%$question) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
1373 |
is( exists $error->{RETURN_IMPOSSIBLE}, 1, 'RETURN_IMPOSSIBLE must be set' ); |
1375 |
is( exists $error->{RETURN_IMPOSSIBLE}, 1, 'RETURN_IMPOSSIBLE must be set' ); |
1374 |
is( $error->{branch_to_return}, $homebranch->{branchcode} ); |
1376 |
is( $error->{branch_to_return}, $homebranch->{branchcode}, 'branch_to_return matches homebranch' ); |
1375 |
|
1377 |
|
1376 |
# TODO t::lib::Mocks::mock_preference('AllowReturnToBranch', 'homeorholdingbranch'); |
1378 |
# TODO t::lib::Mocks::mock_preference('AllowReturnToBranch', 'homeorholdingbranch'); |
1377 |
}; |
1379 |
}; |
Lines 1410-1451
subtest 'AddIssue & AllowReturnToBranch' => sub {
Link Here
|
1410 |
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' ); |
1412 |
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' ); |
1411 |
## Can be issued from homebranch |
1413 |
## Can be issued from homebranch |
1412 |
set_userenv($homebranch); |
1414 |
set_userenv($homebranch); |
1413 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue ); |
1415 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue, 'AllowReturnToBranch - anywhere | Can be issued from homebranch'); |
1414 |
set_userenv($holdingbranch); AddIssue( $patron_1, $item->{barcode} ); # Reinsert the original issue |
1416 |
set_userenv($holdingbranch); AddIssue( $patron_1, $item->{barcode} ); # Reinsert the original issue |
1415 |
## Can be issued from holdinbranch |
1417 |
## Can be issued from holdinbranch |
1416 |
set_userenv($holdingbranch); |
1418 |
set_userenv($holdingbranch); |
1417 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue ); |
1419 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue, 'AllowReturnToBranch - anywhere | Can be issued from holdingbranch'); |
1418 |
set_userenv($holdingbranch); AddIssue( $patron_1, $item->{barcode} ); # Reinsert the original issue |
1420 |
set_userenv($holdingbranch); AddIssue( $patron_1, $item->{barcode} ); # Reinsert the original issue |
1419 |
## Can be issued from another branch |
1421 |
## Can be issued from another branch |
1420 |
set_userenv($otherbranch); |
1422 |
set_userenv($otherbranch); |
1421 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue ); |
1423 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue, 'AllowReturnToBranch - anywhere | Can be issued from otherbranch'); |
1422 |
set_userenv($holdingbranch); AddIssue( $patron_1, $item->{barcode} ); # Reinsert the original issue |
1424 |
set_userenv($holdingbranch); AddIssue( $patron_1, $item->{barcode} ); # Reinsert the original issue |
1423 |
|
1425 |
|
1424 |
# AllowReturnToBranch == holdinbranch |
1426 |
# AllowReturnToBranch == holdinbranch |
1425 |
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'holdingbranch' ); |
1427 |
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'holdingbranch' ); |
1426 |
## Cannot be issued from homebranch |
1428 |
## Cannot be issued from homebranch |
1427 |
set_userenv($homebranch); |
1429 |
set_userenv($homebranch); |
1428 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), '' ); |
1430 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), '', 'AllowReturnToBranch - holdingbranch | Cannot be issued from homebranch'); |
1429 |
## Can be issued from holdingbranch |
1431 |
## Can be issued from holdingbranch |
1430 |
set_userenv($holdingbranch); |
1432 |
set_userenv($holdingbranch); |
1431 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue ); |
1433 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue, 'AllowReturnToBranch - holdingbranch | Can be issued from holdingbranch'); |
1432 |
set_userenv($holdingbranch); AddIssue( $patron_1, $item->{barcode} ); # Reinsert the original issue |
1434 |
set_userenv($holdingbranch); AddIssue( $patron_1, $item->{barcode} ); # Reinsert the original issue |
1433 |
## Cannot be issued from another branch |
1435 |
## Cannot be issued from another branch |
1434 |
set_userenv($otherbranch); |
1436 |
set_userenv($otherbranch); |
1435 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), '' ); |
1437 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), '', 'AllowReturnToBranch - holdingbranch | Cannot be issued from otherbranch'); |
1436 |
|
1438 |
|
1437 |
# AllowReturnToBranch == homebranch |
1439 |
# AllowReturnToBranch == homebranch |
1438 |
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'homebranch' ); |
1440 |
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'homebranch' ); |
1439 |
## Can be issued from homebranch |
1441 |
## Can be issued from homebranch |
1440 |
set_userenv($homebranch); |
1442 |
set_userenv($homebranch); |
1441 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue ); |
1443 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue, 'AllowReturnToBranch - homebranch | Can be issued from homebranch' ); |
1442 |
set_userenv($holdingbranch); AddIssue( $patron_1, $item->{barcode} ); # Reinsert the original issue |
1444 |
set_userenv($holdingbranch); AddIssue( $patron_1, $item->{barcode} ); # Reinsert the original issue |
1443 |
## Cannot be issued from holdinbranch |
1445 |
## Cannot be issued from holdinbranch |
1444 |
set_userenv($holdingbranch); |
1446 |
set_userenv($holdingbranch); |
1445 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), '' ); |
1447 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), '', 'AllowReturnToBranch - homebranch | Cannot be issued from holdingbranch' ); |
1446 |
## Cannot be issued from another branch |
1448 |
## Cannot be issued from another branch |
1447 |
set_userenv($otherbranch); |
1449 |
set_userenv($otherbranch); |
1448 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), '' ); |
1450 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), '', 'AllowReturnToBranch - homebranch | Cannot be issued from otherbranch' ); |
1449 |
# TODO t::lib::Mocks::mock_preference('AllowReturnToBranch', 'homeorholdingbranch'); |
1451 |
# TODO t::lib::Mocks::mock_preference('AllowReturnToBranch', 'homeorholdingbranch'); |
1450 |
}; |
1452 |
}; |
1451 |
|
1453 |
|
1452 |
- |
|
|