|
Lines 527-533
subtest 'suspend and resume tests' => sub {
Link Here
|
| 527 |
->json_is( |
527 |
->json_is( |
| 528 |
'/end_date', |
528 |
'/end_date', |
| 529 |
output_pref( { dt => $date, dateformat => 'iso', dateonly => 1 } ) |
529 |
output_pref( { dt => $date, dateformat => 'iso', dateonly => 1 } ) |
| 530 |
)->header_is( Location => "/api/v1/holds/" . $hold->id . "/suspension", 'The Location header is set' ); |
530 |
)->header_is( Location => "/api/v1/holds/" . $hold->id . "/suspension", 'The Location header is set' ); |
| 531 |
|
531 |
|
| 532 |
$t->delete_ok( "//$userid:$password@/api/v1/holds/" . $hold->id . "/suspension" ) |
532 |
$t->delete_ok( "//$userid:$password@/api/v1/holds/" . $hold->id . "/suspension" ) |
| 533 |
->status_is( 204, 'REST3.2.4' ) |
533 |
->status_is( 204, 'REST3.2.4' ) |
|
Lines 1236-1242
subtest 'pickup_locations() tests' => sub {
Link Here
|
| 1236 |
|
1236 |
|
| 1237 |
subtest 'edit() tests' => sub { |
1237 |
subtest 'edit() tests' => sub { |
| 1238 |
|
1238 |
|
| 1239 |
plan tests => 47; |
1239 |
plan tests => 63; |
| 1240 |
|
1240 |
|
| 1241 |
$schema->storage->txn_begin; |
1241 |
$schema->storage->txn_begin; |
| 1242 |
|
1242 |
|
|
Lines 1293-1304
subtest 'edit() tests' => sub {
Link Here
|
| 1293 |
{ |
1293 |
{ |
| 1294 |
class => "Koha::Holds", |
1294 |
class => "Koha::Holds", |
| 1295 |
value => { |
1295 |
value => { |
| 1296 |
biblionumber => $biblio->biblionumber, |
1296 |
biblionumber => $biblio->biblionumber, |
| 1297 |
branchcode => $library_3->branchcode, |
1297 |
branchcode => $library_3->branchcode, |
| 1298 |
itemnumber => undef, |
1298 |
itemnumber => undef, |
| 1299 |
priority => 1, |
1299 |
item_level_hold => 0, |
| 1300 |
reservedate => '2022-01-01', |
1300 |
priority => 1, |
| 1301 |
expirationdate => '2022-03-01' |
1301 |
reservedate => '2022-01-01', |
|
|
1302 |
expirationdate => '2022-03-01' |
| 1302 |
} |
1303 |
} |
| 1303 |
} |
1304 |
} |
| 1304 |
); |
1305 |
); |
|
Lines 1359-1372
subtest 'edit() tests' => sub {
Link Here
|
| 1359 |
{ |
1360 |
{ |
| 1360 |
class => "Koha::Holds", |
1361 |
class => "Koha::Holds", |
| 1361 |
value => { |
1362 |
value => { |
| 1362 |
biblionumber => $biblio->biblionumber, |
1363 |
biblionumber => $biblio->biblionumber, |
| 1363 |
branchcode => $library_3->branchcode, |
1364 |
branchcode => $library_3->branchcode, |
| 1364 |
itemnumber => $item->itemnumber, |
1365 |
itemnumber => $item->itemnumber, |
| 1365 |
priority => 1, |
1366 |
item_level_hold => 1, |
| 1366 |
suspend => 0, |
1367 |
priority => 1, |
| 1367 |
suspend_until => undef, |
1368 |
suspend => 0, |
| 1368 |
reservedate => '2022-01-01', |
1369 |
suspend_until => undef, |
| 1369 |
expirationdate => '2022-03-01' |
1370 |
reservedate => '2022-01-01', |
|
|
1371 |
expirationdate => '2022-03-01' |
| 1370 |
} |
1372 |
} |
| 1371 |
} |
1373 |
} |
| 1372 |
); |
1374 |
); |
|
Lines 1420-1425
subtest 'edit() tests' => sub {
Link Here
|
| 1420 |
is( $item_hold->reservedate, '2022-01-02', 'Hold date changed correctly' ); |
1422 |
is( $item_hold->reservedate, '2022-01-02', 'Hold date changed correctly' ); |
| 1421 |
is( $item_hold->expirationdate, '2022-03-02', 'Expiration date changed correctly' ); |
1423 |
is( $item_hold->expirationdate, '2022-03-02', 'Expiration date changed correctly' ); |
| 1422 |
|
1424 |
|
|
|
1425 |
# Test item_level and item_id parameters |
| 1426 |
my $item_2 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } ); |
| 1427 |
|
| 1428 |
# Test changing item_id on an existing item-level hold |
| 1429 |
$item_hold_data = { item_id => $item_2->itemnumber }; |
| 1430 |
|
| 1431 |
$t->patch_ok( "//$userid:$password@/api/v1/holds/" . $item_hold->id => json => $item_hold_data )->status_is(200); |
| 1432 |
|
| 1433 |
$item_hold->discard_changes; |
| 1434 |
is( $item_hold->itemnumber, $item_2->itemnumber, 'Item ID changed correctly on item-level hold' ); |
| 1435 |
is( $item_hold->item_level_hold, 1, 'Hold remains item-level' ); |
| 1436 |
|
| 1437 |
# Test converting item-level hold to biblio-level hold |
| 1438 |
$item_hold_data = { |
| 1439 |
item_id => undef, |
| 1440 |
item_level => Mojo::JSON->false |
| 1441 |
}; |
| 1442 |
|
| 1443 |
$t->patch_ok( "//$userid:$password@/api/v1/holds/" . $item_hold->id => json => $item_hold_data )->status_is(200); |
| 1444 |
|
| 1445 |
$item_hold->discard_changes; |
| 1446 |
is( $item_hold->itemnumber, undef, 'Item ID removed - converted to biblio-level hold' ); |
| 1447 |
is( $item_hold->item_level_hold, 0, 'Hold is now biblio-level' ); |
| 1448 |
|
| 1449 |
# Test converting biblio-level hold to item-level hold |
| 1450 |
$biblio_hold_data = { |
| 1451 |
item_id => $item->itemnumber, |
| 1452 |
item_level => Mojo::JSON->true |
| 1453 |
}; |
| 1454 |
|
| 1455 |
$t->patch_ok( "//$userid:$password@/api/v1/holds/" . $biblio_hold->id => json => $biblio_hold_data ) |
| 1456 |
->status_is(200); |
| 1457 |
|
| 1458 |
$biblio_hold->discard_changes; |
| 1459 |
is( $biblio_hold->itemnumber, $item->itemnumber, 'Item ID set - converted to item-level hold' ); |
| 1460 |
is( $biblio_hold->item_level_hold, 1, 'Hold is now item-level' ); |
| 1461 |
|
| 1462 |
# Test setting item_level flag without changing item_id |
| 1463 |
$item_hold_data = { |
| 1464 |
item_id => $item->itemnumber, |
| 1465 |
item_level => Mojo::JSON->true |
| 1466 |
}; |
| 1467 |
|
| 1468 |
# First make it biblio-level |
| 1469 |
$item_hold->update( { itemnumber => undef, item_level_hold => 0 } ); |
| 1470 |
|
| 1471 |
$t->patch_ok( "//$userid:$password@/api/v1/holds/" . $item_hold->id => json => $item_hold_data )->status_is(200); |
| 1472 |
|
| 1473 |
$item_hold->discard_changes; |
| 1474 |
is( $item_hold->itemnumber, $item->itemnumber, 'Item ID set correctly' ); |
| 1475 |
is( $item_hold->item_level_hold, 1, 'item_level flag set correctly' ); |
| 1476 |
|
| 1423 |
$schema->storage->txn_rollback; |
1477 |
$schema->storage->txn_rollback; |
| 1424 |
|
1478 |
|
| 1425 |
}; |
1479 |
}; |
| 1426 |
- |
|
|