Lines 383-389
subtest 'get_public() tests' => sub {
Link Here
|
383 |
|
383 |
|
384 |
subtest 'pickup_locations() tests' => sub { |
384 |
subtest 'pickup_locations() tests' => sub { |
385 |
|
385 |
|
386 |
plan tests => 15; |
386 |
plan tests => 16; |
387 |
|
387 |
|
388 |
$schema->storage->txn_begin; |
388 |
$schema->storage->txn_begin; |
389 |
|
389 |
|
Lines 476-481
subtest 'pickup_locations() tests' => sub {
Link Here
|
476 |
. "patron_id=" . $patron->id . "&_order_by=marc_org_code" ) |
476 |
. "patron_id=" . $patron->id . "&_order_by=marc_org_code" ) |
477 |
->json_is( [ $library_1_api, $library_2_api, $library_3_api, $library_5_api ] ); |
477 |
->json_is( [ $library_1_api, $library_2_api, $library_3_api, $library_5_api ] ); |
478 |
|
478 |
|
|
|
479 |
subtest 'Pagination and AllowHoldPolicyOverride tests' => sub { |
480 |
|
481 |
plan tests => 27; |
482 |
|
483 |
t::lib::Mocks::mock_preference( 'AllowHoldPolicyOverride', 1 ); |
484 |
|
485 |
$t->get_ok( "//$userid:$password@/api/v1/biblios/" . $biblio->id . "/pickup_locations?" . "patron_id=" . $patron->id . "&_order_by=marc_org_code" . "&_per_page=1" ) |
486 |
->json_is( [$library_1_api] ) |
487 |
->header_is( 'X-Total-Count', '4', '4 is the count for libraries with pickup_location=1' ) |
488 |
->header_is( 'X-Base-Total-Count', '4', '4 is the count for libraries with pickup_location=1' ) |
489 |
->header_unlike( 'Link', qr|rel="prev"| ) |
490 |
->header_like( 'Link', qr#(_per_page=1.*\&_page=2.*|_page=2.*\&_per_page=1.*)>\; rel="next"# ) |
491 |
->header_like( 'Link', qr#(_per_page=1.*\&_page=1.*|_page=1.*\&_per_page=1).*>\; rel="first"# ) |
492 |
->header_like( 'Link', qr#(_per_page=1.*\&_page=4.*|_page=4.*\&_per_page=1).*>\; rel="last"# ); |
493 |
|
494 |
$t->get_ok( "//$userid:$password@/api/v1/biblios/" |
495 |
. $biblio->id |
496 |
. "/pickup_locations?" |
497 |
. "patron_id=" |
498 |
. $patron->id |
499 |
. "&_order_by=marc_org_code" |
500 |
. "&_per_page=1&_page=3" ) # force the needs_override=1 check |
501 |
->json_is( [$library_3_api] ) |
502 |
->header_is( 'X-Total-Count', '4', '4 is the count for libraries with pickup_location=1' ) |
503 |
->header_is( 'X-Base-Total-Count', '4', '4 is the count for libraries with pickup_location=1' ) |
504 |
->header_like( 'Link', qr#(_per_page=1.*\&_page=2.*|_page=2.*\&_per_page=1.*)>\; rel="prev"# ) |
505 |
->header_like( 'Link', qr#(_per_page=1.*\&_page=4.*|_page=4.*\&_per_page=1.*)>\; rel="next"# ) |
506 |
->header_like( 'Link', qr#(_per_page=1.*\&_page=1.*|_page=1.*\&_per_page=1).*>\; rel="first"# ) |
507 |
->header_like( 'Link', qr#(_per_page=1.*\&_page=4.*|_page=4.*\&_per_page=1).*>\; rel="last"# ); |
508 |
|
509 |
t::lib::Mocks::mock_preference( 'AllowHoldPolicyOverride', 0 ); |
510 |
|
511 |
$t->get_ok( "//$userid:$password@/api/v1/biblios/" . $biblio->id . "/pickup_locations?" . "patron_id=" . $patron->id . "&_order_by=marc_org_code" . "&_per_page=1" ) |
512 |
->json_is( [$library_1_api] ) |
513 |
->header_is( 'X-Total-Count', '2' ) |
514 |
->header_is( 'X-Base-Total-Count', '2' ) |
515 |
->header_unlike( 'Link', qr|rel="prev"| ) |
516 |
->header_like( 'Link', qr#(_per_page=1.*\&_page=2.*|_page=2.*\&_per_page=1.*)>\; rel="next"# ) |
517 |
->header_like( 'Link', qr#(_per_page=1.*\&_page=1.*|_page=1.*\&_per_page=1).*>\; rel="first"# ) |
518 |
->header_like( 'Link', qr#(_per_page=1.*\&_page=2.*|_page=2.*\&_per_page=1).*>\; rel="last"# ); |
519 |
}; |
520 |
|
479 |
my $deleted_patron = $builder->build_object({ class => 'Koha::Patrons' }); |
521 |
my $deleted_patron = $builder->build_object({ class => 'Koha::Patrons' }); |
480 |
my $deleted_patron_id = $deleted_patron->id; |
522 |
my $deleted_patron_id = $deleted_patron->id; |
481 |
$deleted_patron->delete; |
523 |
$deleted_patron->delete; |
482 |
- |
|
|