Lines 71-77
subtest 'list() tests' => sub {
Link Here
|
71 |
# One city created, should get returned |
71 |
# One city created, should get returned |
72 |
$t->get_ok("//$userid:$password@/api/v1/cities") |
72 |
$t->get_ok("//$userid:$password@/api/v1/cities") |
73 |
->status_is(200) |
73 |
->status_is(200) |
74 |
->json_is( [Koha::REST::V1::Cities::_to_api( $city->TO_JSON )] ); |
74 |
->json_is( [$city->to_api] ); |
75 |
|
75 |
|
76 |
my $another_city = $builder->build_object( |
76 |
my $another_city = $builder->build_object( |
77 |
{ class => 'Koha::Cities', value => { city_country => $city->city_country } } ); |
77 |
{ class => 'Koha::Cities', value => { city_country => $city->city_country } } ); |
Lines 80-100
subtest 'list() tests' => sub {
Link Here
|
80 |
# Two cities created, they should both be returned |
80 |
# Two cities created, they should both be returned |
81 |
$t->get_ok("//$userid:$password@/api/v1/cities") |
81 |
$t->get_ok("//$userid:$password@/api/v1/cities") |
82 |
->status_is(200) |
82 |
->status_is(200) |
83 |
->json_is([Koha::REST::V1::Cities::_to_api($city->TO_JSON), |
83 |
->json_is([$city->to_api, |
84 |
Koha::REST::V1::Cities::_to_api($another_city->TO_JSON), |
84 |
$another_city->to_api, |
85 |
Koha::REST::V1::Cities::_to_api($city_with_another_country->TO_JSON) |
85 |
$city_with_another_country->to_api |
86 |
] ); |
86 |
] ); |
87 |
|
87 |
|
88 |
# Filtering works, two cities sharing city_country |
88 |
# Filtering works, two cities sharing city_country |
89 |
$t->get_ok("//$userid:$password@/api/v1/cities?country=" . $city->city_country ) |
89 |
$t->get_ok("//$userid:$password@/api/v1/cities?country=" . $city->city_country ) |
90 |
->status_is(200) |
90 |
->status_is(200) |
91 |
->json_is([ Koha::REST::V1::Cities::_to_api($city->TO_JSON), |
91 |
->json_is([ $city->to_api, |
92 |
Koha::REST::V1::Cities::_to_api($another_city->TO_JSON) |
92 |
$another_city->to_api |
93 |
]); |
93 |
]); |
94 |
|
94 |
|
95 |
$t->get_ok("//$userid:$password@/api/v1/cities?name=" . $city->city_name ) |
95 |
$t->get_ok("//$userid:$password@/api/v1/cities?name=" . $city->city_name ) |
96 |
->status_is(200) |
96 |
->status_is(200) |
97 |
->json_is( [Koha::REST::V1::Cities::_to_api($city->TO_JSON)] ); |
97 |
->json_is( [$city->to_api] ); |
98 |
|
98 |
|
99 |
# Warn on unsupported query parameter |
99 |
# Warn on unsupported query parameter |
100 |
$t->get_ok("//$userid:$password@/api/v1/cities?city_blah=blah" ) |
100 |
$t->get_ok("//$userid:$password@/api/v1/cities?city_blah=blah" ) |
Lines 137-143
subtest 'get() tests' => sub {
Link Here
|
137 |
|
137 |
|
138 |
$t->get_ok( "//$userid:$password@/api/v1/cities/" . $city->cityid ) |
138 |
$t->get_ok( "//$userid:$password@/api/v1/cities/" . $city->cityid ) |
139 |
->status_is(200) |
139 |
->status_is(200) |
140 |
->json_is(Koha::REST::V1::Cities::_to_api($city->TO_JSON)); |
140 |
->json_is($city->to_api); |
141 |
|
141 |
|
142 |
$t->get_ok( "//$unauth_userid:$password@/api/v1/cities/" . $city->cityid ) |
142 |
$t->get_ok( "//$unauth_userid:$password@/api/v1/cities/" . $city->cityid ) |
143 |
->status_is(403); |
143 |
->status_is(403); |
144 |
- |
|
|