|
Lines 20-26
use Modern::Perl;
Link Here
|
| 20 |
use CGI qw ( -utf8 ); |
20 |
use CGI qw ( -utf8 ); |
| 21 |
|
21 |
|
| 22 |
use Test::NoWarnings; |
22 |
use Test::NoWarnings; |
| 23 |
use Test::More tests => 16; |
23 |
use Test::More tests => 17; |
| 24 |
use Test::MockModule; |
24 |
use Test::MockModule; |
| 25 |
use t::lib::Mocks; |
25 |
use t::lib::Mocks; |
| 26 |
use t::lib::TestBuilder; |
26 |
use t::lib::TestBuilder; |
|
Lines 472-484
subtest 'Holds test' => sub {
Link Here
|
| 472 |
|
472 |
|
| 473 |
t::lib::Mocks::mock_preference( 'AllowHoldsOnDamagedItems', 0 ); |
473 |
t::lib::Mocks::mock_preference( 'AllowHoldsOnDamagedItems', 0 ); |
| 474 |
|
474 |
|
|
|
475 |
my $pickup_library = $builder->build_object( |
| 476 |
{ |
| 477 |
class => 'Koha::Libraries', |
| 478 |
value => { |
| 479 |
pickup_location => 1, |
| 480 |
} |
| 481 |
} |
| 482 |
); |
| 483 |
|
| 475 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
484 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 476 |
|
485 |
|
| 477 |
my $item = $builder->build_sample_item( { damaged => 1 } ); |
486 |
my $item = $builder->build_sample_item( { damaged => 1, library => $pickup_library->branchcode, } ); |
| 478 |
|
487 |
|
| 479 |
my $query = CGI->new; |
488 |
my $query = CGI->new; |
| 480 |
$query->param( 'patron_id', $patron->borrowernumber ); |
489 |
$query->param( 'patron_id', $patron->borrowernumber ); |
| 481 |
$query->param( 'bib_id', $item->biblionumber ); |
490 |
$query->param( 'bib_id', $item->biblionumber ); |
|
|
491 |
$query->param( 'pickup_location', $pickup_library->branchcode ); |
| 482 |
|
492 |
|
| 483 |
my $reply = C4::ILSDI::Services::HoldTitle($query); |
493 |
my $reply = C4::ILSDI::Services::HoldTitle($query); |
| 484 |
is( $reply->{code}, 'damaged', "Item damaged" ); |
494 |
is( $reply->{code}, 'damaged', "Item damaged" ); |
|
Lines 1263-1265
subtest 'Bug 34893: ILS-DI can return the wrong patron for AuthenticatePatron' =
Link Here
|
| 1263 |
|
1273 |
|
| 1264 |
$schema->storage->txn_rollback; |
1274 |
$schema->storage->txn_rollback; |
| 1265 |
}; |
1275 |
}; |
| 1266 |
- |
1276 |
|
|
|
1277 |
subtest 'Bug 23669: PreventReservesOnSamePeriod with ILS-DI' => sub { |
| 1278 |
|
| 1279 |
plan tests => 4; |
| 1280 |
|
| 1281 |
$schema->storage->txn_begin; |
| 1282 |
|
| 1283 |
# Set up the test environment |
| 1284 |
t::lib::Mocks::mock_preference( 'PreventReservesOnSamePeriod', 1 ); |
| 1285 |
t::lib::Mocks::mock_preference( 'AllowHoldDateInFuture', 1 ); |
| 1286 |
|
| 1287 |
my $pickup_library = $builder->build_object( |
| 1288 |
{ |
| 1289 |
class => 'Koha::Libraries', |
| 1290 |
value => { |
| 1291 |
pickup_location => 1, |
| 1292 |
} |
| 1293 |
} |
| 1294 |
); |
| 1295 |
|
| 1296 |
# Create a patron |
| 1297 |
my $patron = $builder->build_object( |
| 1298 |
{ |
| 1299 |
class => 'Koha::Patrons', |
| 1300 |
} |
| 1301 |
); |
| 1302 |
|
| 1303 |
# Create a record and items |
| 1304 |
my $biblio = $builder->build_sample_biblio(); |
| 1305 |
my $item = $builder->build_sample_item( |
| 1306 |
{ |
| 1307 |
biblionumber => $biblio->biblionumber, |
| 1308 |
library => $pickup_library->branchcode, |
| 1309 |
} |
| 1310 |
); |
| 1311 |
|
| 1312 |
Koha::CirculationRules->set_rule( |
| 1313 |
{ |
| 1314 |
categorycode => undef, |
| 1315 |
itemtype => undef, |
| 1316 |
branchcode => undef, |
| 1317 |
rule_name => 'reservesallowed', |
| 1318 |
rule_value => 99, |
| 1319 |
} |
| 1320 |
); |
| 1321 |
|
| 1322 |
Koha::CirculationRules->set_rule( |
| 1323 |
{ |
| 1324 |
categorycode => undef, |
| 1325 |
itemtype => undef, |
| 1326 |
branchcode => undef, |
| 1327 |
rule_name => 'holds_per_record', |
| 1328 |
rule_value => 99, |
| 1329 |
} |
| 1330 |
); |
| 1331 |
|
| 1332 |
# Place an existing hold with specific dates |
| 1333 |
my $reserve_id = C4::Reserves::AddReserve( |
| 1334 |
{ |
| 1335 |
branchcode => $item->homebranch, |
| 1336 |
borrowernumber => $patron->borrowernumber, |
| 1337 |
biblionumber => $biblio->biblionumber, |
| 1338 |
priority => 1, |
| 1339 |
reservation_date => '2023-11-01', |
| 1340 |
expiration_date => '2023-11-10', |
| 1341 |
} |
| 1342 |
); |
| 1343 |
|
| 1344 |
# Attempt to place a new hold with overlapping dates through ILS-DI |
| 1345 |
my $query = CGI->new; |
| 1346 |
$query->param( 'pickup_location', $pickup_library->branchcode ); |
| 1347 |
$query->param( 'patron_id', $patron->borrowernumber ); |
| 1348 |
$query->param( 'bib_id', $biblio->biblionumber ); |
| 1349 |
$query->param( 'start_date', '2023-11-05' ); |
| 1350 |
$query->param( 'expiry_date', '2023-11-15' ); |
| 1351 |
|
| 1352 |
my $reply = C4::ILSDI::Services::HoldTitle($query); |
| 1353 |
|
| 1354 |
# Verify that the hold is rejected |
| 1355 |
is( $reply->{code}, 'overlap', 'Hold is rejected due to overlapping dates' ); |
| 1356 |
|
| 1357 |
# Now try with non-overlapping dates |
| 1358 |
$query->param( 'start_date', '2023-11-15' ); |
| 1359 |
$query->param( 'expiry_date', '2023-11-20' ); |
| 1360 |
|
| 1361 |
$reply = C4::ILSDI::Services::HoldTitle($query); |
| 1362 |
|
| 1363 |
# Verify that the hold is accepted |
| 1364 |
is( $reply->{code}, undef, 'Hold is accepted with non-overlapping dates' ); |
| 1365 |
|
| 1366 |
# Test with item-level hold |
| 1367 |
$query->param( 'item_id', $item->itemnumber ); |
| 1368 |
$query->param( 'start_date', '2023-11-05' ); |
| 1369 |
$query->param( 'expiry_date', '2023-11-15' ); |
| 1370 |
|
| 1371 |
$reply = C4::ILSDI::Services::HoldItem($query); |
| 1372 |
|
| 1373 |
# Verify that the hold is rejected |
| 1374 |
is( $reply->{code}, 'overlap', 'Item-level hold is rejected due to overlapping dates' ); |
| 1375 |
|
| 1376 |
# Now try with non-overlapping dates |
| 1377 |
$query->param( 'start_date', '2023-11-25' ); |
| 1378 |
$query->param( 'expiry_date', '2023-11-30' ); |
| 1379 |
|
| 1380 |
$reply = C4::ILSDI::Services::HoldItem($query); |
| 1381 |
|
| 1382 |
# Verify that the hold is accepted |
| 1383 |
is( $reply->{code}, undef, 'Item-level hold is accepted with non-overlapping dates' ); |
| 1384 |
|
| 1385 |
$schema->storage->txn_rollback; |
| 1386 |
}; |