View | Details | Raw Unified | Return to bug 30133
Collapse All | Expand All

(-)a/t/db_dependent/api/v1/items.t (-2 / +43 lines)
Lines 144-150 subtest 'get() tests' => sub { Link Here
144
144
145
subtest 'pickup_locations() tests' => sub {
145
subtest 'pickup_locations() tests' => sub {
146
146
147
    plan tests => 15;
147
    plan tests => 16;
148
148
149
    $schema->storage->txn_begin;
149
    $schema->storage->txn_begin;
150
150
Lines 237-242 subtest 'pickup_locations() tests' => sub { Link Here
237
          . "patron_id=" . $patron->id . "&_order_by=marc_org_code" )
237
          . "patron_id=" . $patron->id . "&_order_by=marc_org_code" )
238
      ->json_is( [ $library_1_api, $library_2_api, $library_3_api, $library_5_api ] );
238
      ->json_is( [ $library_1_api, $library_2_api, $library_3_api, $library_5_api ] );
239
239
240
    subtest 'Pagination and AllowHoldPolicyOverride tests' => sub {
241
242
        plan tests => 27;
243
244
        t::lib::Mocks::mock_preference( 'AllowHoldPolicyOverride', 1 );
245
246
        $t->get_ok( "//$userid:$password@/api/v1/items/" . $item->id . "/pickup_locations?" . "patron_id=" . $patron->id . "&_order_by=marc_org_code" . "&_per_page=1" )
247
          ->json_is( [$library_1_api] )
248
          ->header_is( 'X-Total-Count', '4', '4 is the count for libraries with pickup_location=1' )
249
          ->header_is( 'X-Base-Total-Count', '4', '4 is the count for libraries with pickup_location=1' )
250
          ->header_unlike( 'Link', qr|rel="prev"| )
251
          ->header_like( 'Link', qr#(_per_page=1.*\&_page=2.*|_page=2.*\&_per_page=1.*)>\; rel="next"# )
252
          ->header_like( 'Link', qr#(_per_page=1.*\&_page=1.*|_page=1.*\&_per_page=1).*>\; rel="first"# )
253
          ->header_like( 'Link', qr#(_per_page=1.*\&_page=4.*|_page=4.*\&_per_page=1).*>\; rel="last"# );
254
255
        $t->get_ok( "//$userid:$password@/api/v1/items/"
256
              . $item->id
257
              . "/pickup_locations?"
258
              . "patron_id="
259
              . $patron->id
260
              . "&_order_by=marc_org_code"
261
              . "&_per_page=1&_page=3" )    # force the needs_override=1 check
262
          ->json_is( [$library_3_api] )
263
          ->header_is( 'X-Total-Count', '4', '4 is the count for libraries with pickup_location=1' )
264
          ->header_is( 'X-Base-Total-Count', '4', '4 is the count for libraries with pickup_location=1' )
265
          ->header_like( 'Link', qr#(_per_page=1.*\&_page=2.*|_page=2.*\&_per_page=1.*)>\; rel="prev"# )
266
          ->header_like( 'Link', qr#(_per_page=1.*\&_page=4.*|_page=4.*\&_per_page=1.*)>\; rel="next"# )
267
          ->header_like( 'Link', qr#(_per_page=1.*\&_page=1.*|_page=1.*\&_per_page=1).*>\; rel="first"# )
268
          ->header_like( 'Link', qr#(_per_page=1.*\&_page=4.*|_page=4.*\&_per_page=1).*>\; rel="last"# );
269
270
        t::lib::Mocks::mock_preference( 'AllowHoldPolicyOverride', 0 );
271
272
        $t->get_ok( "//$userid:$password@/api/v1/items/" . $item->id . "/pickup_locations?" . "patron_id=" . $patron->id . "&_order_by=marc_org_code" . "&_per_page=1" )
273
          ->json_is( [$library_1_api] )
274
          ->header_is( 'X-Total-Count', '2' )
275
          ->header_is( 'X-Base-Total-Count', '2' )
276
          ->header_unlike( 'Link', qr|rel="prev"| )
277
          ->header_like( 'Link', qr#(_per_page=1.*\&_page=2.*|_page=2.*\&_per_page=1.*)>\; rel="next"# )
278
          ->header_like( 'Link', qr#(_per_page=1.*\&_page=1.*|_page=1.*\&_per_page=1).*>\; rel="first"# )
279
          ->header_like( 'Link', qr#(_per_page=1.*\&_page=2.*|_page=2.*\&_per_page=1).*>\; rel="last"# );
280
    };
281
240
    my $deleted_patron = $builder->build_object({ class => 'Koha::Patrons' });
282
    my $deleted_patron = $builder->build_object({ class => 'Koha::Patrons' });
241
    my $deleted_patron_id = $deleted_patron->id;
283
    my $deleted_patron_id = $deleted_patron->id;
242
    $deleted_patron->delete;
284
    $deleted_patron->delete;
243
- 

Return to bug 30133