View | Details | Raw Unified | Return to bug 27680
Collapse All | Expand All

(-)a/t/db_dependent/Koha/REST/Plugin/Objects.t (-9 / +44 lines)
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 => 14;
199
    plan tests => 31;
200
200
201
    $schema->storage->txn_begin;
201
    $schema->storage->txn_begin;
202
202
Lines 205-227 subtest 'objects.search helper, sorting on mapped column' => sub { Link Here
205
205
206
    $builder->build_object({ class => 'Koha::Cities', value => { city_name => 'A', city_country => 'Argentina' } });
206
    $builder->build_object({ class => 'Koha::Cities', value => { city_name => 'A', city_country => 'Argentina' } });
207
    $builder->build_object({ class => 'Koha::Cities', value => { city_name => 'B', city_country => 'Argentina' } });
207
    $builder->build_object({ class => 'Koha::Cities', value => { city_name => 'B', city_country => 'Argentina' } });
208
    $builder->build_object({ class => 'Koha::Cities', value => { city_name => 'C', city_country => 'Argentina' } });
209
    $builder->build_object({ class => 'Koha::Cities', value => { city_name => 'C', city_country => 'Belarus' } });
208
210
209
    my $t = Test::Mojo->new;
211
    my $t = Test::Mojo->new;
210
    $t->get_ok('/cities?_order_by=%2Bname&_order_by=+country')
212
    diag("Multi-param: traditional");
213
    $t->get_ok('/cities?_order_by=+name&_order_by=-country')
211
      ->status_is(200)
214
      ->status_is(200)
212
      ->json_has('/0')
215
      ->json_has('/0')
213
      ->json_has('/1')
216
      ->json_has('/1')
214
      ->json_hasnt('/2')
215
      ->json_is('/0/name' => 'A')
217
      ->json_is('/0/name' => 'A')
216
      ->json_is('/1/name' => 'B');
218
      ->json_is('/1/name' => 'B')
217
219
      ->json_is('/2/name' => 'C')
220
      ->json_is('/2/country' => 'Belarus')
221
      ->json_is('/3/name' => 'C')
222
      ->json_is('/3/country' => 'Argentina')
223
      ->json_hasnt('/4');
224
225
    diag("Multi-param: with []");
226
    $t->get_ok('/cities?_order_by[]=+name&_order_by[]=-country')
227
      ->status_is(200)
228
      ->json_has('/0')
229
      ->json_has('/1')
230
      ->json_is('/0/name' => 'A')
231
      ->json_is('/1/name' => 'B')
232
      ->json_is('/2/name' => 'C')
233
      ->json_is('/2/country' => 'Belarus')
234
      ->json_is('/3/name' => 'C')
235
      ->json_is('/3/country' => 'Argentina')
236
      ->json_hasnt('/4');
237
238
    diag("CSV-param");
239
    $t->get_ok('/cities?_order_by=+name,-country')
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');
250
251
    diag("Single-param");
218
    $t->get_ok('/cities?_order_by=-name')
252
    $t->get_ok('/cities?_order_by=-name')
219
      ->status_is(200)
253
      ->status_is(200)
220
      ->json_has('/0')
254
      ->json_has('/0')
221
      ->json_has('/1')
255
      ->json_has('/1')
222
      ->json_hasnt('/2')
256
      ->json_is('/0/name' => 'C')
223
      ->json_is('/0/name' => 'B')
257
      ->json_is('/1/name' => 'C')
224
      ->json_is('/1/name' => 'A');
258
      ->json_is('/2/name' => 'B')
259
      ->json_is('/3/name' => 'A')
260
      ->json_hasnt('/4');
225
261
226
    $schema->storage->txn_rollback;
262
    $schema->storage->txn_rollback;
227
};
263
};
228
- 

Return to bug 27680