Lines 17-23
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 1; |
20 |
use Test::More tests => 2; |
21 |
use Test::Mojo; |
21 |
use Test::Mojo; |
22 |
use Test::Warn; |
22 |
use Test::Warn; |
23 |
|
23 |
|
Lines 35-40
t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 );
Link Here
|
35 |
|
35 |
|
36 |
my $t = Test::Mojo->new('Koha::REST::V1'); |
36 |
my $t = Test::Mojo->new('Koha::REST::V1'); |
37 |
|
37 |
|
|
|
38 |
subtest 'get() tests' => sub { |
39 |
|
40 |
plan tests => 18; |
41 |
|
42 |
$schema->storage->txn_begin; |
43 |
|
44 |
my $patron = $builder->build_object( |
45 |
{ |
46 |
class => 'Koha::Patrons', |
47 |
value => { flags => 0 } |
48 |
} |
49 |
); |
50 |
my $password = 'thePassword123'; |
51 |
$patron->set_password( { password => $password, skip_validation => 1 } ); |
52 |
$patron->discard_changes; |
53 |
my $userid = $patron->userid; |
54 |
|
55 |
my $biblio = $builder->build_sample_biblio({ |
56 |
title => 'The unbearable lightness of being', |
57 |
author => 'Milan Kundera' |
58 |
}); |
59 |
$t->get_ok("//$userid:$password@/api/v1/biblios/" . $biblio->biblionumber) |
60 |
->status_is(403); |
61 |
|
62 |
$patron->flags(4)->store; |
63 |
|
64 |
$t->get_ok( "//$userid:$password@/api/v1/biblios/" . $biblio->biblionumber |
65 |
=> { Accept => 'application/weird+format' } ) |
66 |
->status_is(406) |
67 |
->json_is( [ "application/json", |
68 |
"application/marcxml+xml", |
69 |
"application/marc-in-json", |
70 |
"application/marc" ] ); |
71 |
|
72 |
$t->get_ok( "//$userid:$password@/api/v1/biblios/" . $biblio->biblionumber |
73 |
=> { Accept => 'application/json' } ) |
74 |
->status_is(200) |
75 |
->json_is( '/title', 'The unbearable lightness of being' ) |
76 |
->json_is( '/author', 'Milan Kundera' ); |
77 |
|
78 |
$t->get_ok( "//$userid:$password@/api/v1/biblios/" . $biblio->biblionumber |
79 |
=> { Accept => 'application/marcxml+xml' } ) |
80 |
->status_is(200); |
81 |
|
82 |
$t->get_ok( "//$userid:$password@/api/v1/biblios/" . $biblio->biblionumber |
83 |
=> { Accept => 'application/marc-in-json' } ) |
84 |
->status_is(200); |
85 |
|
86 |
$t->get_ok( "//$userid:$password@/api/v1/biblios/" . $biblio->biblionumber |
87 |
=> { Accept => 'application/marc' } ) |
88 |
->status_is(200); |
89 |
|
90 |
$biblio->delete; |
91 |
$t->get_ok( "//$userid:$password@/api/v1/biblios/" . $biblio->biblionumber |
92 |
=> { Accept => 'application/marc' } ) |
93 |
->status_is(404) |
94 |
->json_is( '/error', 'Object not found.' ); |
95 |
|
96 |
$schema->storage->txn_rollback; |
97 |
}; |
98 |
|
38 |
subtest 'delete() tests' => sub { |
99 |
subtest 'delete() tests' => sub { |
39 |
|
100 |
|
40 |
plan tests => 7; |
101 |
plan tests => 7; |
41 |
- |
|
|