|
Lines 60-66
my $itemtype = $builder->build(
Link Here
|
| 60 |
value => { notforloan => undef, rentalcharge => 0 } |
60 |
value => { notforloan => undef, rentalcharge => 0 } |
| 61 |
} |
61 |
} |
| 62 |
)->{itemtype}; |
62 |
)->{itemtype}; |
| 63 |
my $patron_category = $builder->build({ source => 'Category', value => { enrolmentfee => 0 } }); |
63 |
my $patron_category = $builder->build({ source => 'Category', value => { categorycode => 'NOT_X', category_type => 'P', enrolmentfee => 0 } }); |
| 64 |
|
64 |
|
| 65 |
my $CircControl = C4::Context->preference('CircControl'); |
65 |
my $CircControl = C4::Context->preference('CircControl'); |
| 66 |
my $HomeOrHoldingBranch = C4::Context->preference('HomeOrHoldingBranch'); |
66 |
my $HomeOrHoldingBranch = C4::Context->preference('HomeOrHoldingBranch'); |
|
Lines 1105-1111
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
| 1105 |
$biblionumber, |
1105 |
$biblionumber, |
| 1106 |
); |
1106 |
); |
| 1107 |
|
1107 |
|
| 1108 |
my $patron = $builder->build({ source => 'Borrower', value => { branchcode => $library->{branchcode} } } ); |
1108 |
my $patron = $builder->build({ source => 'Borrower', value => { branchcode => $library->{branchcode}, categorycode => $patron_category->{categorycode} } } ); |
| 1109 |
|
1109 |
|
| 1110 |
my $issue = AddIssue( $patron, $barcode ); |
1110 |
my $issue = AddIssue( $patron, $barcode ); |
| 1111 |
UpdateFine( |
1111 |
UpdateFine( |
|
Lines 1130-1142
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
| 1130 |
} |
1130 |
} |
| 1131 |
|
1131 |
|
| 1132 |
subtest 'CanBookBeIssued & AllowReturnToBranch' => sub { |
1132 |
subtest 'CanBookBeIssued & AllowReturnToBranch' => sub { |
| 1133 |
plan tests => 26; |
1133 |
plan tests => 23; |
| 1134 |
|
1134 |
|
| 1135 |
my $homebranch = $builder->build( { source => 'Branch' } ); |
1135 |
my $homebranch = $builder->build( { source => 'Branch' } ); |
| 1136 |
my $holdingbranch = $builder->build( { source => 'Branch' } ); |
1136 |
my $holdingbranch = $builder->build( { source => 'Branch' } ); |
| 1137 |
my $otherbranch = $builder->build( { source => 'Branch' } ); |
1137 |
my $otherbranch = $builder->build( { source => 'Branch' } ); |
| 1138 |
my $patron_1 = $builder->build( { source => 'Borrower' } ); |
1138 |
my $patron_1 = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); |
| 1139 |
my $patron_2 = $builder->build( { source => 'Borrower' } ); |
1139 |
my $patron_2 = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); |
| 1140 |
|
1140 |
|
| 1141 |
my $biblioitem = $builder->build( { source => 'Biblioitem' } ); |
1141 |
my $biblioitem = $builder->build( { source => 'Biblioitem' } ); |
| 1142 |
my $item = $builder->build( |
1142 |
my $item = $builder->build( |
|
Lines 1165-1203
subtest 'CanBookBeIssued & AllowReturnToBranch' => sub {
Link Here
|
| 1165 |
## Can be issued from homebranch |
1165 |
## Can be issued from homebranch |
| 1166 |
set_userenv($homebranch); |
1166 |
set_userenv($homebranch); |
| 1167 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
1167 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
| 1168 |
is( keys(%$error), 0, 'There should not be any errors (impossible)' ); |
1168 |
is( keys(%$error) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
| 1169 |
is( keys(%$alerts), 0, 'There should not be any alerts' ); |
1169 |
is( exists $question->{ISSUED_TO_ANOTHER}, 1, 'ISSUED_TO_ANOTHER must be set' ); |
| 1170 |
is( exists $question->{ISSUED_TO_ANOTHER}, 1 ); |
|
|
| 1171 |
## Can be issued from holdingbranch |
1170 |
## Can be issued from holdingbranch |
| 1172 |
set_userenv($holdingbranch); |
1171 |
set_userenv($holdingbranch); |
| 1173 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
1172 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
| 1174 |
is( keys(%$error), 0, 'There should not be any errors (impossible)' ); |
1173 |
is( keys(%$error) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
| 1175 |
is( keys(%$alerts), 0, 'There should not be any alerts' ); |
1174 |
is( exists $question->{ISSUED_TO_ANOTHER}, 1, 'ISSUED_TO_ANOTHER must be set' ); |
| 1176 |
is( exists $question->{ISSUED_TO_ANOTHER}, 1 ); |
|
|
| 1177 |
## Can be issued from another branch |
1175 |
## Can be issued from another branch |
| 1178 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
1176 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
| 1179 |
is( keys(%$error), 0, 'There should not be any errors (impossible)' ); |
1177 |
is( keys(%$error) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
| 1180 |
is( keys(%$alerts), 0, 'There should not be any alerts' ); |
1178 |
is( exists $question->{ISSUED_TO_ANOTHER}, 1, 'ISSUED_TO_ANOTHER must be set' ); |
| 1181 |
is( exists $question->{ISSUED_TO_ANOTHER}, 1 ); |
|
|
| 1182 |
|
1179 |
|
| 1183 |
# AllowReturnToBranch == holdingbranch |
1180 |
# AllowReturnToBranch == holdingbranch |
| 1184 |
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'holdingbranch' ); |
1181 |
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'holdingbranch' ); |
| 1185 |
## Cannot be issued from homebranch |
1182 |
## Cannot be issued from homebranch |
| 1186 |
set_userenv($homebranch); |
1183 |
set_userenv($homebranch); |
| 1187 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
1184 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
| 1188 |
is( keys(%$question) + keys(%$alerts), 0 ); |
1185 |
is( keys(%$question) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
| 1189 |
is( exists $error->{RETURN_IMPOSSIBLE}, 1 ); |
1186 |
is( exists $error->{RETURN_IMPOSSIBLE}, 1, 'RETURN_IMPOSSIBLE must be set' ); |
| 1190 |
is( $error->{branch_to_return}, $holdingbranch->{branchcode} ); |
1187 |
is( $error->{branch_to_return}, $holdingbranch->{branchcode} ); |
| 1191 |
## Can be issued from holdinbranch |
1188 |
## Can be issued from holdinbranch |
| 1192 |
set_userenv($holdingbranch); |
1189 |
set_userenv($holdingbranch); |
| 1193 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
1190 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
| 1194 |
is( keys(%$error) + keys(%$alerts), 0 ); |
1191 |
is( keys(%$error) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
| 1195 |
is( exists $question->{ISSUED_TO_ANOTHER}, 1 ); |
1192 |
is( exists $question->{ISSUED_TO_ANOTHER}, 1, 'ISSUED_TO_ANOTHER must be set' ); |
| 1196 |
## Cannot be issued from another branch |
1193 |
## Cannot be issued from another branch |
| 1197 |
set_userenv($otherbranch); |
1194 |
set_userenv($otherbranch); |
| 1198 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
1195 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
| 1199 |
is( keys(%$question) + keys(%$alerts), 0 ); |
1196 |
is( keys(%$question) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
| 1200 |
is( exists $error->{RETURN_IMPOSSIBLE}, 1 ); |
1197 |
is( exists $error->{RETURN_IMPOSSIBLE}, 1, 'RETURN_IMPOSSIBLE must be set' ); |
| 1201 |
is( $error->{branch_to_return}, $holdingbranch->{branchcode} ); |
1198 |
is( $error->{branch_to_return}, $holdingbranch->{branchcode} ); |
| 1202 |
|
1199 |
|
| 1203 |
# AllowReturnToBranch == homebranch |
1200 |
# AllowReturnToBranch == homebranch |
|
Lines 1205-1223
subtest 'CanBookBeIssued & AllowReturnToBranch' => sub {
Link Here
|
| 1205 |
## Can be issued from holdinbranch |
1202 |
## Can be issued from holdinbranch |
| 1206 |
set_userenv($homebranch); |
1203 |
set_userenv($homebranch); |
| 1207 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
1204 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
| 1208 |
is( keys(%$error) + keys(%$alerts), 0 ); |
1205 |
is( keys(%$error) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
| 1209 |
is( exists $question->{ISSUED_TO_ANOTHER}, 1 ); |
1206 |
is( exists $question->{ISSUED_TO_ANOTHER}, 1, 'ISSUED_TO_ANOTHER must be set' ); |
| 1210 |
## Cannot be issued from holdinbranch |
1207 |
## Cannot be issued from holdinbranch |
| 1211 |
set_userenv($holdingbranch); |
1208 |
set_userenv($holdingbranch); |
| 1212 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
1209 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
| 1213 |
is( keys(%$question) + keys(%$alerts), 0 ); |
1210 |
is( keys(%$question) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
| 1214 |
is( exists $error->{RETURN_IMPOSSIBLE}, 1 ); |
1211 |
is( exists $error->{RETURN_IMPOSSIBLE}, 1, 'RETURN_IMPOSSIBLE must be set' ); |
| 1215 |
is( $error->{branch_to_return}, $homebranch->{branchcode} ); |
1212 |
is( $error->{branch_to_return}, $homebranch->{branchcode} ); |
| 1216 |
## Cannot be issued from holdinbranch |
1213 |
## Cannot be issued from holdinbranch |
| 1217 |
set_userenv($otherbranch); |
1214 |
set_userenv($otherbranch); |
| 1218 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
1215 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
| 1219 |
is( keys(%$question) + keys(%$alerts), 0 ); |
1216 |
is( keys(%$question) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
| 1220 |
is( exists $error->{RETURN_IMPOSSIBLE}, 1 ); |
1217 |
is( exists $error->{RETURN_IMPOSSIBLE}, 1, 'RETURN_IMPOSSIBLE must be set' ); |
| 1221 |
is( $error->{branch_to_return}, $homebranch->{branchcode} ); |
1218 |
is( $error->{branch_to_return}, $homebranch->{branchcode} ); |
| 1222 |
|
1219 |
|
| 1223 |
# TODO t::lib::Mocks::mock_preference('AllowReturnToBranch', 'homeorholdingbranch'); |
1220 |
# TODO t::lib::Mocks::mock_preference('AllowReturnToBranch', 'homeorholdingbranch'); |
|
Lines 1229-1236
subtest 'AddIssue & AllowReturnToBranch' => sub {
Link Here
|
| 1229 |
my $homebranch = $builder->build( { source => 'Branch' } ); |
1226 |
my $homebranch = $builder->build( { source => 'Branch' } ); |
| 1230 |
my $holdingbranch = $builder->build( { source => 'Branch' } ); |
1227 |
my $holdingbranch = $builder->build( { source => 'Branch' } ); |
| 1231 |
my $otherbranch = $builder->build( { source => 'Branch' } ); |
1228 |
my $otherbranch = $builder->build( { source => 'Branch' } ); |
| 1232 |
my $patron_1 = $builder->build( { source => 'Borrower' } ); |
1229 |
my $patron_1 = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); |
| 1233 |
my $patron_2 = $builder->build( { source => 'Borrower' } ); |
1230 |
my $patron_2 = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); |
| 1234 |
|
1231 |
|
| 1235 |
my $biblioitem = $builder->build( { source => 'Biblioitem' } ); |
1232 |
my $biblioitem = $builder->build( { source => 'Biblioitem' } ); |
| 1236 |
my $item = $builder->build( |
1233 |
my $item = $builder->build( |
|
Lines 1300-1306
subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub {
Link Here
|
| 1300 |
plan tests => 8; |
1297 |
plan tests => 8; |
| 1301 |
|
1298 |
|
| 1302 |
my $library = $builder->build( { source => 'Branch' } ); |
1299 |
my $library = $builder->build( { source => 'Branch' } ); |
| 1303 |
my $patron = $builder->build( { source => 'Borrower', value => { gonenoaddress => undef, lost => undef, debarred => undef, borrowernotes => "" } } ); |
1300 |
my $patron = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); |
| 1304 |
|
1301 |
|
| 1305 |
my $biblioitem_1 = $builder->build( { source => 'Biblioitem' } ); |
1302 |
my $biblioitem_1 = $builder->build( { source => 'Biblioitem' } ); |
| 1306 |
my $item_1 = $builder->build( |
1303 |
my $item_1 = $builder->build( |
|
Lines 1339-1362
subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub {
Link Here
|
| 1339 |
|
1336 |
|
| 1340 |
t::lib::Mocks::mock_preference( 'OverduesBlockCirc', 'confirmation' ); |
1337 |
t::lib::Mocks::mock_preference( 'OverduesBlockCirc', 'confirmation' ); |
| 1341 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
1338 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
| 1342 |
is( keys(%$error) + keys(%$alerts), 0, 'No key for error and alert ' . keys(%$error) . ' ' . keys(%$alerts) ); |
1339 |
is( keys(%$error) + keys(%$alerts), 0, 'No key for error and alert' . str($error, $question, $alerts) ); |
| 1343 |
is( $question->{USERBLOCKEDOVERDUE}, 1, 'OverduesBlockCirc=confirmation, USERBLOCKEDOVERDUE should be set for question' ); |
1340 |
is( $question->{USERBLOCKEDOVERDUE}, 1, 'OverduesBlockCirc=confirmation, USERBLOCKEDOVERDUE should be set for question' ); |
| 1344 |
|
1341 |
|
| 1345 |
t::lib::Mocks::mock_preference( 'OverduesBlockCirc', 'block' ); |
1342 |
t::lib::Mocks::mock_preference( 'OverduesBlockCirc', 'block' ); |
| 1346 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
1343 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
| 1347 |
is( keys(%$question) + keys(%$alerts), 0, 'No key for question and alert ' . keys(%$question) . ' ' . keys(%$alerts) ); |
1344 |
is( keys(%$question) + keys(%$alerts), 0, 'No key for question and alert ' . str($error, $question, $alerts) ); |
| 1348 |
is( $error->{USERBLOCKEDOVERDUE}, 1, 'OverduesBlockCirc=block, USERBLOCKEDOVERDUE should be set for error' ); |
1345 |
is( $error->{USERBLOCKEDOVERDUE}, 1, 'OverduesBlockCirc=block, USERBLOCKEDOVERDUE should be set for error' ); |
| 1349 |
|
1346 |
|
| 1350 |
# Patron cannot issue item_1, they are debarred |
1347 |
# Patron cannot issue item_1, they are debarred |
| 1351 |
my $tomorrow = DateTime->today( time_zone => C4::Context->tz() )->add( days => 1 ); |
1348 |
my $tomorrow = DateTime->today( time_zone => C4::Context->tz() )->add( days => 1 ); |
| 1352 |
Koha::Patron::Debarments::AddDebarment( { borrowernumber => $patron->{borrowernumber}, expiration => $tomorrow } ); |
1349 |
Koha::Patron::Debarments::AddDebarment( { borrowernumber => $patron->{borrowernumber}, expiration => $tomorrow } ); |
| 1353 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
1350 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
| 1354 |
is( keys(%$question) + keys(%$alerts), 0, 'No key for question and alert ' . keys(%$question) . ' ' . keys(%$alerts) ); |
1351 |
is( keys(%$question) + keys(%$alerts), 0, 'No key for question and alert ' . str($error, $question, $alerts) ); |
| 1355 |
is( $error->{USERBLOCKEDWITHENDDATE}, output_pref( { dt => $tomorrow, dateformat => 'sql', dateonly => 1 } ), 'USERBLOCKEDWITHENDDATE should be tomorrow' ); |
1352 |
is( $error->{USERBLOCKEDWITHENDDATE}, output_pref( { dt => $tomorrow, dateformat => 'sql', dateonly => 1 } ), 'USERBLOCKEDWITHENDDATE should be tomorrow' ); |
| 1356 |
|
1353 |
|
| 1357 |
Koha::Patron::Debarments::AddDebarment( { borrowernumber => $patron->{borrowernumber} } ); |
1354 |
Koha::Patron::Debarments::AddDebarment( { borrowernumber => $patron->{borrowernumber} } ); |
| 1358 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
1355 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
| 1359 |
is( keys(%$question) + keys(%$alerts), 0, 'No key for question and alert ' . keys(%$question) . ' ' . keys(%$alerts) ); |
1356 |
is( keys(%$question) + keys(%$alerts), 0, 'No key for question and alert ' . str($error, $question, $alerts) ); |
| 1360 |
is( $error->{USERBLOCKEDNOENDDATE}, '9999-12-31', 'USERBLOCKEDNOENDDATE should be 9999-12-31 for unlimited debarments' ); |
1357 |
is( $error->{USERBLOCKEDNOENDDATE}, '9999-12-31', 'USERBLOCKEDNOENDDATE should be 9999-12-31 for unlimited debarments' ); |
| 1361 |
}; |
1358 |
}; |
| 1362 |
|
1359 |
|
|
Lines 1364-1370
subtest 'CanBookBeIssued + Statistic patrons "X"' => sub {
Link Here
|
| 1364 |
plan tests => 1; |
1361 |
plan tests => 1; |
| 1365 |
|
1362 |
|
| 1366 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
1363 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
| 1367 |
my $patron_category = $builder->build_object( |
1364 |
my $patron_category_x = $builder->build_object( |
| 1368 |
{ |
1365 |
{ |
| 1369 |
class => 'Koha::Patron::Categories', |
1366 |
class => 'Koha::Patron::Categories', |
| 1370 |
value => { category_type => 'X' } |
1367 |
value => { category_type => 'X' } |
|
Lines 1374-1380
subtest 'CanBookBeIssued + Statistic patrons "X"' => sub {
Link Here
|
| 1374 |
{ |
1371 |
{ |
| 1375 |
class => 'Koha::Patrons', |
1372 |
class => 'Koha::Patrons', |
| 1376 |
value => { |
1373 |
value => { |
| 1377 |
categorycode => $patron_category->categorycode, |
1374 |
categorycode => $patron_category_x->categorycode, |
| 1378 |
gonenoaddress => undef, |
1375 |
gonenoaddress => undef, |
| 1379 |
lost => undef, |
1376 |
lost => undef, |
| 1380 |
debarred => undef, |
1377 |
debarred => undef, |
|
Lines 1516-1522
subtest 'CanBookBeIssued + AllowMultipleIssuesOnABiblio' => sub {
Link Here
|
| 1516 |
plan tests => 5; |
1513 |
plan tests => 5; |
| 1517 |
|
1514 |
|
| 1518 |
my $library = $builder->build( { source => 'Branch' } ); |
1515 |
my $library = $builder->build( { source => 'Branch' } ); |
| 1519 |
my $patron = $builder->build( { source => 'Borrower' } ); |
1516 |
my $patron = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); |
| 1520 |
|
1517 |
|
| 1521 |
my $biblioitem = $builder->build( { source => 'Biblioitem' } ); |
1518 |
my $biblioitem = $builder->build( { source => 'Biblioitem' } ); |
| 1522 |
my $biblionumber = $biblioitem->{biblionumber}; |
1519 |
my $biblionumber = $biblioitem->{biblionumber}; |
|
Lines 1550-1579
subtest 'CanBookBeIssued + AllowMultipleIssuesOnABiblio' => sub {
Link Here
|
| 1550 |
|
1547 |
|
| 1551 |
t::lib::Mocks::mock_preference('AllowMultipleIssuesOnABiblio', 0); |
1548 |
t::lib::Mocks::mock_preference('AllowMultipleIssuesOnABiblio', 0); |
| 1552 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
1549 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
| 1553 |
is( keys(%$error) + keys(%$alerts), 0, 'No error or alert should be raised' ); |
1550 |
is( keys(%$error) + keys(%$alerts), 0, 'No error or alert should be raised' . str($error, $question, $alerts) ); |
| 1554 |
is( $question->{BIBLIO_ALREADY_ISSUED}, 1, 'BIBLIO_ALREADY_ISSUED question flag should be set if AllowMultipleIssuesOnABiblio=0 and issue already exists' ); |
1551 |
is( $question->{BIBLIO_ALREADY_ISSUED}, 1, 'BIBLIO_ALREADY_ISSUED question flag should be set if AllowMultipleIssuesOnABiblio=0 and issue already exists' . str($error, $question, $alerts) ); |
| 1555 |
|
1552 |
|
| 1556 |
t::lib::Mocks::mock_preference('AllowMultipleIssuesOnABiblio', 1); |
1553 |
t::lib::Mocks::mock_preference('AllowMultipleIssuesOnABiblio', 1); |
| 1557 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
1554 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
| 1558 |
is( keys(%$error) + keys(%$question) + keys(%$alerts), 0, 'No BIBLIO_ALREADY_ISSUED flag should be set if AllowMultipleIssuesOnABiblio=1' ); |
1555 |
is( keys(%$error) + keys(%$question) + keys(%$alerts), 0, 'No BIBLIO_ALREADY_ISSUED flag should be set if AllowMultipleIssuesOnABiblio=1' . str($error, $question, $alerts) ); |
| 1559 |
|
1556 |
|
| 1560 |
# Add a subscription |
1557 |
# Add a subscription |
| 1561 |
Koha::Subscription->new({ biblionumber => $biblionumber })->store; |
1558 |
Koha::Subscription->new({ biblionumber => $biblionumber })->store; |
| 1562 |
|
1559 |
|
| 1563 |
t::lib::Mocks::mock_preference('AllowMultipleIssuesOnABiblio', 0); |
1560 |
t::lib::Mocks::mock_preference('AllowMultipleIssuesOnABiblio', 0); |
| 1564 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
1561 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
| 1565 |
is( keys(%$error) + keys(%$question) + keys(%$alerts), 0, 'No BIBLIO_ALREADY_ISSUED flag should be set if it is a subscription' ); |
1562 |
is( keys(%$error) + keys(%$question) + keys(%$alerts), 0, 'No BIBLIO_ALREADY_ISSUED flag should be set if it is a subscription' . str($error, $question, $alerts) ); |
| 1566 |
|
1563 |
|
| 1567 |
t::lib::Mocks::mock_preference('AllowMultipleIssuesOnABiblio', 1); |
1564 |
t::lib::Mocks::mock_preference('AllowMultipleIssuesOnABiblio', 1); |
| 1568 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
1565 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
| 1569 |
is( keys(%$error) + keys(%$question) + keys(%$alerts), 0, 'No BIBLIO_ALREADY_ISSUED flag should be set if it is a subscription' ); |
1566 |
is( keys(%$error) + keys(%$question) + keys(%$alerts), 0, 'No BIBLIO_ALREADY_ISSUED flag should be set if it is a subscription' . str($error, $question, $alerts) ); |
| 1570 |
}; |
1567 |
}; |
| 1571 |
|
1568 |
|
| 1572 |
subtest 'AddReturn + CumulativeRestrictionPeriods' => sub { |
1569 |
subtest 'AddReturn + CumulativeRestrictionPeriods' => sub { |
| 1573 |
plan tests => 8; |
1570 |
plan tests => 8; |
| 1574 |
|
1571 |
|
| 1575 |
my $library = $builder->build( { source => 'Branch' } ); |
1572 |
my $library = $builder->build( { source => 'Branch' } ); |
| 1576 |
my $patron = $builder->build( { source => 'Borrower' } ); |
1573 |
my $patron = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); |
| 1577 |
|
1574 |
|
| 1578 |
# Add 2 items |
1575 |
# Add 2 items |
| 1579 |
my $biblioitem_1 = $builder->build( { source => 'Biblioitem' } ); |
1576 |
my $biblioitem_1 = $builder->build( { source => 'Biblioitem' } ); |
|
Lines 1704-1710
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
| 1704 |
t::lib::Mocks::mock_preference('MaxFine', '100'); |
1701 |
t::lib::Mocks::mock_preference('MaxFine', '100'); |
| 1705 |
|
1702 |
|
| 1706 |
my $library = $builder->build( { source => 'Branch' } ); |
1703 |
my $library = $builder->build( { source => 'Branch' } ); |
| 1707 |
my $patron = $builder->build( { source => 'Borrower' } ); |
1704 |
my $patron = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); |
| 1708 |
|
1705 |
|
| 1709 |
my $biblioitem = $builder->build( { source => 'Biblioitem' } ); |
1706 |
my $biblioitem = $builder->build( { source => 'Biblioitem' } ); |
| 1710 |
my $item = $builder->build( |
1707 |
my $item = $builder->build( |
|
Lines 1777-1785
subtest 'Set waiting flag' => sub {
Link Here
|
| 1777 |
plan tests => 4; |
1774 |
plan tests => 4; |
| 1778 |
|
1775 |
|
| 1779 |
my $library_1 = $builder->build( { source => 'Branch' } ); |
1776 |
my $library_1 = $builder->build( { source => 'Branch' } ); |
| 1780 |
my $patron_1 = $builder->build( { source => 'Borrower', value => { branchcode => $library_1->{branchcode} } } ); |
1777 |
my $patron_1 = $builder->build( { source => 'Borrower', value => { branchcode => $library_1->{branchcode}, categorycode => $patron_category->{categorycode} } } ); |
| 1781 |
my $library_2 = $builder->build( { source => 'Branch' } ); |
1778 |
my $library_2 = $builder->build( { source => 'Branch' } ); |
| 1782 |
my $patron_2 = $builder->build( { source => 'Borrower', value => { branchcode => $library_2->{branchcode} } } ); |
1779 |
my $patron_2 = $builder->build( { source => 'Borrower', value => { branchcode => $library_2->{branchcode}, categorycode => $patron_category->{categorycode} } } ); |
| 1783 |
|
1780 |
|
| 1784 |
my $biblio = $builder->build( { source => 'Biblio' } ); |
1781 |
my $biblio = $builder->build( { source => 'Biblio' } ); |
| 1785 |
my $biblioitem = $builder->build( { source => 'Biblioitem', value => { biblionumber => $biblio->{biblionumber} } } ); |
1782 |
my $biblioitem = $builder->build( { source => 'Biblioitem', value => { biblionumber => $biblio->{biblionumber} } } ); |
|
Lines 1829-1831
sub set_userenv {
Link Here
|
| 1829 |
my ( $library ) = @_; |
1826 |
my ( $library ) = @_; |
| 1830 |
C4::Context->set_userenv(0,0,0,'firstname','surname', $library->{branchcode}, $library->{branchname}, '', '', ''); |
1827 |
C4::Context->set_userenv(0,0,0,'firstname','surname', $library->{branchcode}, $library->{branchname}, '', '', ''); |
| 1831 |
} |
1828 |
} |
| 1832 |
- |
1829 |
|
|
|
1830 |
sub str { |
| 1831 |
my ( $error, $question, $alert ) = @_; |
| 1832 |
my $s; |
| 1833 |
$s = %$error ? ' (error: ' . join( ' ', keys %$error ) . ')' : ''; |
| 1834 |
$s .= %$question ? ' (question: ' . join( ' ', keys %$question ) . ')' : ''; |
| 1835 |
$s .= %$alert ? ' (alert: ' . join( ' ', keys %$alert ) . ')' : ''; |
| 1836 |
return $s; |
| 1837 |
} |