Lines 169-175
subtest 'list() tests' => sub {
Link Here
|
169 |
# Three requests exist, expect all three to be returned |
169 |
# Three requests exist, expect all three to be returned |
170 |
$t->get_ok("//$userid:$password@/api/v1/ill/requests") |
170 |
$t->get_ok("//$userid:$password@/api/v1/ill/requests") |
171 |
->status_is(200) |
171 |
->status_is(200) |
172 |
->json_is( [ $req_1->to_api, $req_2->to_api, $ret->to_api ]); |
172 |
->json_is( [ $req_1->to_api({user=> $librarian}), $req_2->to_api({user=> $librarian}), $ret->to_api({user=> $librarian}) ]); |
173 |
|
173 |
|
174 |
my $status_query = encode_json({ status => 'REQ' }); |
174 |
my $status_query = encode_json({ status => 'REQ' }); |
175 |
my $status_alias_query = encode_json({ status_av => $av_code }); |
175 |
my $status_alias_query = encode_json({ status_av => $av_code }); |
Lines 177-205
subtest 'list() tests' => sub {
Link Here
|
177 |
# x-koha-embed: +strings |
177 |
# x-koha-embed: +strings |
178 |
# Two requests exist with status 'REQ', expect them to be returned |
178 |
# Two requests exist with status 'REQ', expect them to be returned |
179 |
# One of which also has a status_alias, expect that to be in that request's body |
179 |
# One of which also has a status_alias, expect that to be in that request's body |
180 |
$t->get_ok("//$userid:$password@/api/v1/ill/requests?q=$status_query" => {"x-koha-embed" => "+strings"} ) |
180 |
$t->get_ok( "//$userid:$password@/api/v1/ill/requests?q=$status_query" => { "x-koha-embed" => "+strings" } ) |
181 |
->status_is(200) |
181 |
->status_is(200)->json_is( |
182 |
->json_is( [ |
182 |
[ |
183 |
{ _strings => { status => $response_status }, %{$req_1->to_api} }, |
183 |
{ _strings => { status => $response_status }, %{ $req_1->to_api( { user => $librarian } ) } }, |
184 |
{ _strings => { status => $response_status, status_av => $response_status_av }, %{$req_2->to_api} } |
184 |
{ |
185 |
] |
185 |
_strings => { status => $response_status, status_av => $response_status_av }, |
|
|
186 |
%{ $req_2->to_api( { user => $librarian } ) } |
187 |
} |
188 |
] |
186 |
); |
189 |
); |
187 |
|
190 |
|
188 |
# One request with status_alias 'print_copy' exists, expect that to be returned |
191 |
# One request with status_alias 'print_copy' exists, expect that to be returned |
189 |
$t->get_ok("//$userid:$password@/api/v1/ill/requests?q=$status_alias_query" => {"x-koha-embed" => "+strings"} ) |
192 |
$t->get_ok( "//$userid:$password@/api/v1/ill/requests?q=$status_alias_query" => { "x-koha-embed" => "+strings" } ) |
190 |
->status_is(200) |
193 |
->status_is(200)->json_is( |
191 |
->json_is( [ |
194 |
[ |
192 |
{ _strings => { status => $response_status, status_av => $response_status_av }, %{$req_2->to_api} } |
195 |
{ |
193 |
] |
196 |
_strings => { status => $response_status, status_av => $response_status_av }, |
|
|
197 |
%{ $req_2->to_api( { user => $librarian } ) } |
198 |
} |
199 |
] |
194 |
); |
200 |
); |
195 |
|
201 |
|
196 |
# x-koha-embed: patron |
202 |
# x-koha-embed: patron |
197 |
my $patron_query = encode_json({ borrowernumber => $patron->borrowernumber }); |
203 |
my $patron_query = encode_json({ borrowernumber => $patron->borrowernumber }); |
198 |
|
204 |
|
199 |
# One request related to $patron, make sure it comes back |
205 |
# One request related to $patron, make sure it comes back |
200 |
$t->get_ok("//$userid:$password@/api/v1/ill/requests" => {"x-koha-embed" => "patron"} ) |
206 |
$t->get_ok( "//$userid:$password@/api/v1/ill/requests" => { "x-koha-embed" => "patron" } )->status_is(200) |
201 |
->status_is(200) |
207 |
->json_has( '/0/patron', $patron->to_api( { user => $librarian } ) ); |
202 |
->json_has('/0/patron', $patron->to_api); |
|
|
203 |
|
208 |
|
204 |
# x-koha-embed: comments |
209 |
# x-koha-embed: comments |
205 |
# Create comment |
210 |
# Create comment |
Lines 226-240
subtest 'list() tests' => sub {
Link Here
|
226 |
# ILLHiddenRequestStatuses syspref |
231 |
# ILLHiddenRequestStatuses syspref |
227 |
# Hide 'REQ', expect to return just 1 'RET' |
232 |
# Hide 'REQ', expect to return just 1 'RET' |
228 |
t::lib::Mocks::mock_preference( 'ILLHiddenRequestStatuses', 'REQ' ); |
233 |
t::lib::Mocks::mock_preference( 'ILLHiddenRequestStatuses', 'REQ' ); |
229 |
$t->get_ok( "//$userid:$password@/api/v1/ill/requests" ) |
234 |
$t->get_ok("//$userid:$password@/api/v1/ill/requests")->status_is(200) |
230 |
->status_is(200) |
235 |
->json_is( [ $ret->to_api( { user => $librarian } ) ] ); |
231 |
->json_is( [ $ret->to_api ] ); |
|
|
232 |
|
236 |
|
233 |
# Hide 'RET', expect to return 2 'REQ' |
237 |
# Hide 'RET', expect to return 2 'REQ' |
234 |
t::lib::Mocks::mock_preference( 'ILLHiddenRequestStatuses', 'RET' ); |
238 |
t::lib::Mocks::mock_preference( 'ILLHiddenRequestStatuses', 'RET' ); |
235 |
$t->get_ok( "//$userid:$password@/api/v1/ill/requests?_order_by=staff_notes" ) |
239 |
$t->get_ok("//$userid:$password@/api/v1/ill/requests?_order_by=staff_notes")->status_is(200) |
236 |
->status_is(200) |
240 |
->json_is( [ $req_1->to_api( { user => $librarian } ), $req_2->to_api( { user => $librarian } ) ] ); |
237 |
->json_is( [ $req_1->to_api, $req_2->to_api ]); |
|
|
238 |
|
241 |
|
239 |
# Status code |
242 |
# Status code |
240 |
# Warn on unsupported query parameter |
243 |
# Warn on unsupported query parameter |
241 |
- |
|
|