Bug 27680: Add tests for various ways of passing multi-params
This patch adds unit test to increase the coverage of parameter that accept multiple values. There are a number of different ways end users can send such parameters and we should test to ensure we are recieving the correct option. Options `?param1=this¶m1=that` - traditional multiple pass params `?param1[]=this¶m1[]=that` - php multiple pass params `?param1=this,that` - comma delimited list param `?param1=this|that` - pipe delimited list param Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> (cherry picked from commitd2a43a77aa) Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com> (cherry picked from commit5191ed911d) Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
This commit is contained in:
parent
5f51145efa
commit
3518c975c0
|
|
@ -208,7 +208,7 @@ subtest 'objects.search helper' => sub {
|
|||
|
||||
subtest 'objects.search helper, sorting on mapped column' => sub {
|
||||
|
||||
plan tests => 14;
|
||||
plan tests => 35;
|
||||
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
|
|
@ -217,23 +217,54 @@ subtest 'objects.search helper, sorting on mapped column' => sub {
|
|||
|
||||
$builder->build_object({ class => 'Koha::Cities', value => { city_name => 'A', city_country => 'Argentina' } });
|
||||
$builder->build_object({ class => 'Koha::Cities', value => { city_name => 'B', city_country => 'Argentina' } });
|
||||
$builder->build_object({ class => 'Koha::Cities', value => { city_name => 'C', city_country => 'Argentina' } });
|
||||
$builder->build_object({ class => 'Koha::Cities', value => { city_name => 'C', city_country => 'Belarus' } });
|
||||
|
||||
my $t = Test::Mojo->new;
|
||||
$t->get_ok('/cities?_order_by=%2Bname&_order_by=+country')
|
||||
diag("CSV-param");
|
||||
$t->get_ok('/cities?_order_by=%2Bname,-country')
|
||||
->status_is(200)
|
||||
->json_has('/0')
|
||||
->json_has('/1')
|
||||
->json_hasnt('/2')
|
||||
->json_is('/0/name' => 'A')
|
||||
->json_is('/1/name' => 'B');
|
||||
->json_is('/1/name' => 'B')
|
||||
->json_is('/2/name' => 'C')
|
||||
->json_is('/2/country' => 'Belarus')
|
||||
->json_is('/3/name' => 'C')
|
||||
->json_is('/3/country' => 'Argentina')
|
||||
->json_hasnt('/4');
|
||||
|
||||
diag("Multi-param: traditional");
|
||||
$t->get_ok('/cities?_order_by=%2Bname&_order_by=-country')
|
||||
->status_is(200)
|
||||
->json_has('/0')
|
||||
->json_has('/1')
|
||||
->json_is('/0/name' => 'A')
|
||||
->json_is('/1/name' => 'B')
|
||||
->json_is('/2/name' => 'C')
|
||||
->json_is('/2/country' => 'Belarus')
|
||||
->json_is('/3/name' => 'C')
|
||||
->json_is('/3/country' => 'Argentina')
|
||||
->json_hasnt('/4');
|
||||
|
||||
diag("Pipe-param: Passes validation (treated as a 'single value array or one string), subsequently explodes");
|
||||
$t->get_ok('/cities?_order_by=%2Bname|-country')
|
||||
->status_is(500);
|
||||
|
||||
diag("Multi-param: PHP Style, Passes validation as above, subsequntly explodes");
|
||||
$t->get_ok('/cities?_order_by[]=%2Bname&_order_by[]=-country')
|
||||
->status_is(500);
|
||||
|
||||
diag("Single-param");
|
||||
$t->get_ok('/cities?_order_by=-name')
|
||||
->status_is(200)
|
||||
->json_has('/0')
|
||||
->json_has('/1')
|
||||
->json_hasnt('/2')
|
||||
->json_is('/0/name' => 'B')
|
||||
->json_is('/1/name' => 'A');
|
||||
->json_is('/0/name' => 'C')
|
||||
->json_is('/1/name' => 'C')
|
||||
->json_is('/2/name' => 'B')
|
||||
->json_is('/3/name' => 'A')
|
||||
->json_hasnt('/4');
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue