Lines 20-26
use Modern::Perl;
Link Here
|
20 |
use utf8; |
20 |
use utf8; |
21 |
use Encode; |
21 |
use Encode; |
22 |
|
22 |
|
23 |
use Test::More tests => 4; |
23 |
use Test::More tests => 5; |
24 |
use Test::MockModule; |
24 |
use Test::MockModule; |
25 |
use Test::Mojo; |
25 |
use Test::Mojo; |
26 |
use Test::Warn; |
26 |
use Test::Warn; |
Lines 314-316
subtest 'put() tests' => sub {
Link Here
|
314 |
|
314 |
|
315 |
$schema->storage->txn_rollback; |
315 |
$schema->storage->txn_rollback; |
316 |
}; |
316 |
}; |
317 |
- |
317 |
|
|
|
318 |
|
319 |
|
320 |
subtest 'list() tests' => sub { |
321 |
plan tests => 14; |
322 |
|
323 |
$schema->storage->txn_begin; |
324 |
|
325 |
my $patron = $builder->build_object( |
326 |
{ |
327 |
class => 'Koha::Patrons', |
328 |
value => { flags => 0 } |
329 |
} |
330 |
); |
331 |
my $password = 'thePassword123'; |
332 |
$patron->set_password( { password => $password, skip_validation => 1 } ); |
333 |
$patron->discard_changes; |
334 |
my $userid = $patron->userid; |
335 |
|
336 |
my $authid1 = $builder->build_object({ 'class' => 'Koha::Authorities', value => { |
337 |
marcxml => q|<?xml version="1.0" encoding="UTF-8"?> |
338 |
<record xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.loc.gov/MARC21/slim" xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"> |
339 |
<controlfield tag="001">1001</controlfield> |
340 |
<datafield tag="110" ind1=" " ind2=" "> |
341 |
<subfield code="9">102</subfield> |
342 |
<subfield code="a">My Corporation</subfield> |
343 |
</datafield> |
344 |
</record>| |
345 |
} })->authid; |
346 |
|
347 |
my $authid2 = $builder->build_object({ 'class' => 'Koha::Authorities', value => { |
348 |
marcxml => q|<?xml version="1.0" encoding="UTF-8"?> |
349 |
<record xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.loc.gov/MARC21/slim" xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"> |
350 |
<controlfield tag="001">1001</controlfield> |
351 |
<datafield tag="110" ind1=" " ind2=" "> |
352 |
<subfield code="9">102</subfield> |
353 |
<subfield code="a">My Corporation</subfield> |
354 |
</datafield> |
355 |
</record>| |
356 |
} })->authid; |
357 |
|
358 |
my $search = |
359 |
"[{\"authid\": \"$authid1\"}, {\"authid\": \"$authid2\"}]"; |
360 |
$t->get_ok( |
361 |
"//$userid:$password@/api/v1/authorities/" => { 'x-koha-query' => $search } |
362 |
)->status_is(403); |
363 |
|
364 |
$patron->flags(4)->store; |
365 |
|
366 |
$t->get_ok( "//$userid:$password@/api/v1/authorities/" => |
367 |
{ Accept => 'application/weird+format', 'x-koha-query' => $search } ) |
368 |
->status_is(400); |
369 |
|
370 |
$t->get_ok( "//$userid:$password@/api/v1/authorities/" => |
371 |
{ Accept => 'application/json', 'x-koha-query' => $search } ) |
372 |
->status_is(200); |
373 |
|
374 |
$t->get_ok( "//$userid:$password@/api/v1/authorities/" => |
375 |
{ Accept => 'application/marcxml+xml', 'x-koha-query' => $search } ) |
376 |
->status_is(200); |
377 |
|
378 |
$t->get_ok( "//$userid:$password@/api/v1/authorities/" => |
379 |
{ Accept => 'application/marc-in-json', 'x-koha-query' => $search } ) |
380 |
->status_is(200); |
381 |
|
382 |
$t->get_ok( "//$userid:$password@/api/v1/authorities/" => |
383 |
{ Accept => 'application/marc', 'x-koha-query' => $search } ) |
384 |
->status_is(200); |
385 |
|
386 |
$t->get_ok( "//$userid:$password@/api/v1/authorities/" => |
387 |
{ Accept => 'text/plain', 'x-koha-query' => $search } ) |
388 |
->status_is(200); |
389 |
|
390 |
$schema->storage->txn_rollback; |
391 |
}; |