|
Lines 196-202
subtest 'objects.search helper' => sub {
Link Here
|
| 196 |
|
196 |
|
| 197 |
subtest 'objects.search helper, sorting on mapped column' => sub { |
197 |
subtest 'objects.search helper, sorting on mapped column' => sub { |
| 198 |
|
198 |
|
| 199 |
plan tests => 35; |
199 |
plan tests => 42; |
| 200 |
|
200 |
|
| 201 |
$schema->storage->txn_begin; |
201 |
$schema->storage->txn_begin; |
| 202 |
|
202 |
|
|
Lines 209-215
subtest 'objects.search helper, sorting on mapped column' => sub {
Link Here
|
| 209 |
$builder->build_object({ class => 'Koha::Cities', value => { city_name => 'C', city_country => 'Belarus' } }); |
209 |
$builder->build_object({ class => 'Koha::Cities', value => { city_name => 'C', city_country => 'Belarus' } }); |
| 210 |
|
210 |
|
| 211 |
my $t = Test::Mojo->new; |
211 |
my $t = Test::Mojo->new; |
| 212 |
diag("CSV-param"); |
212 |
# CSV-param |
| 213 |
$t->get_ok('/cities?_order_by=%2Bname,-country') |
213 |
$t->get_ok('/cities?_order_by=%2Bname,-country') |
| 214 |
->status_is(200) |
214 |
->status_is(200) |
| 215 |
->json_has('/0') |
215 |
->json_has('/0') |
|
Lines 222-228
subtest 'objects.search helper, sorting on mapped column' => sub {
Link Here
|
| 222 |
->json_is('/3/country' => 'Argentina') |
222 |
->json_is('/3/country' => 'Argentina') |
| 223 |
->json_hasnt('/4'); |
223 |
->json_hasnt('/4'); |
| 224 |
|
224 |
|
| 225 |
diag("Multi-param: traditional"); |
225 |
# Multi-param: traditional |
| 226 |
$t->get_ok('/cities?_order_by=%2Bname&_order_by=-country') |
226 |
$t->get_ok('/cities?_order_by=%2Bname&_order_by=-country') |
| 227 |
->status_is(200) |
227 |
->status_is(200) |
| 228 |
->json_has('/0') |
228 |
->json_has('/0') |
|
Lines 235-249
subtest 'objects.search helper, sorting on mapped column' => sub {
Link Here
|
| 235 |
->json_is('/3/country' => 'Argentina') |
235 |
->json_is('/3/country' => 'Argentina') |
| 236 |
->json_hasnt('/4'); |
236 |
->json_hasnt('/4'); |
| 237 |
|
237 |
|
| 238 |
diag("Pipe-param: Passes validation (treated as a 'single value array or one string), subsequently explodes"); |
238 |
# Multi-param: PHP Style, Passes validation as above, subsequntly explodes |
| 239 |
$t->get_ok('/cities?_order_by=%2Bname|-country') |
|
|
| 240 |
->status_is(500); |
| 241 |
|
| 242 |
diag("Multi-param: PHP Style, Passes validation as above, subsequntly explodes"); |
| 243 |
$t->get_ok('/cities?_order_by[]=%2Bname&_order_by[]=-country') |
239 |
$t->get_ok('/cities?_order_by[]=%2Bname&_order_by[]=-country') |
| 244 |
->status_is(500); |
240 |
->status_is(200) |
|
|
241 |
->json_has('/0') |
| 242 |
->json_has('/1') |
| 243 |
->json_is('/0/name' => 'A') |
| 244 |
->json_is('/1/name' => 'B') |
| 245 |
->json_is('/2/name' => 'C') |
| 246 |
->json_is('/2/country' => 'Belarus') |
| 247 |
->json_is('/3/name' => 'C') |
| 248 |
->json_is('/3/country' => 'Argentina') |
| 249 |
->json_hasnt('/4'); |
| 245 |
|
250 |
|
| 246 |
diag("Single-param"); |
251 |
# Single-param |
| 247 |
$t->get_ok('/cities?_order_by=-name') |
252 |
$t->get_ok('/cities?_order_by=-name') |
| 248 |
->status_is(200) |
253 |
->status_is(200) |
| 249 |
->json_has('/0') |
254 |
->json_has('/0') |
| 250 |
- |
|
|