From 898aebf2f9f13377bd82e607eabe1304186ccd5a Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 26 Sep 2017 15:17:01 -0300 Subject: [PATCH] Bug 19370: Unit tests --- t/Koha/REST/Plugin/Query.t | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/t/Koha/REST/Plugin/Query.t b/t/Koha/REST/Plugin/Query.t index 8270dc0..f8ad994 100644 --- a/t/Koha/REST/Plugin/Query.t +++ b/t/Koha/REST/Plugin/Query.t @@ -67,9 +67,21 @@ get '/query_full' => sub { ); }; +get '/dbic_merge_sorting' => sub { + my $c = shift; + my $filter = { a => 'a', b => 'b' }; + $filter = $c->dbic_merge_sorting( + { + filter => $filter, + params => { _match => 'exact', _order_by => 'uno|-dos|+tres' } + } + ); + $c->render( json => $filter, status => 200 ); +}; + # The tests -use Test::More tests => 1; +use Test::More tests => 2; use Test::Mojo; subtest 'extract_reserved_params() tests' => sub { @@ -98,3 +110,17 @@ subtest 'extract_reserved_params() tests' => sub { } ); }; + +subtest 'dbic_merge_sorting() tests' => sub { + + plan tests => 5; + + my $t = Test::Mojo->new; + + $t->get_ok('/dbic_merge_sorting') + ->status_is(200) + ->json_is( '/a' => 'a', 'Existing values are kept (a)' ) + ->json_is( '/b' => 'b', 'Existing values are kept (b)' ) + ->json_is( '/order_by' => [ 'uno', { -desc => 'dos' }, { -asc => 'tres' } ] ); +}; + -- 2.7.4