Bugzilla – Attachment 67363 Details for
Bug 19234
Add query parameters handling helpers
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19234: Unit tests for query parameters handling helpers
Bug-19234-Unit-tests-for-query-parameters-handling.patch (text/plain), 3.44 KB, created by
Tomás Cohen Arazi (tcohen)
on 2017-09-26 15:10:07 UTC
(
hide
)
Description:
Bug 19234: Unit tests for query parameters handling helpers
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2017-09-26 15:10:07 UTC
Size:
3.44 KB
patch
obsolete
>From b6431f312dfea8236e1b56b88adc854422323b33 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 1 Sep 2017 11:52:29 -0300 >Subject: [PATCH] Bug 19234: Unit tests for query parameters handling helpers > >This patch adds unit tests for the new query parameters handling Mojo plugin. > >Sponsored-by: Camden County >Sponsored-by: ByWater Solutions > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > t/Koha/REST/Plugin/Query.t | 100 +++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 100 insertions(+) > create mode 100644 t/Koha/REST/Plugin/Query.t > >diff --git a/t/Koha/REST/Plugin/Query.t b/t/Koha/REST/Plugin/Query.t >new file mode 100644 >index 0000000..8270dc0 >--- /dev/null >+++ b/t/Koha/REST/Plugin/Query.t >@@ -0,0 +1,100 @@ >+#!/usr/bin/perl >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+# Dummy app for testing the plugin >+use Mojolicious::Lite; >+ >+app->log->level('error'); >+ >+plugin 'Koha::REST::Plugin::Query'; >+ >+get '/empty' => sub { >+ my $c = shift; >+ $c->render( json => undef, status => 200 ); >+}; >+ >+get '/query' => sub { >+ my $c = shift; >+ my $input = { >+ _page => 2, >+ _per_page => 3, >+ firstname => 'Manuel', >+ surname => 'Cohen Arazi' >+ }; >+ my ( $filtered_params, $reserved_params ) = $c->extract_reserved_params($input); >+ $c->render( >+ json => { >+ filtered_params => $filtered_params, >+ reserved_params => $reserved_params >+ }, >+ status => 200 >+ ); >+}; >+ >+get '/query_full' => sub { >+ my $c = shift; >+ my $input = { >+ _match => 'exact', >+ _order_by => 'blah', >+ _page => 2, >+ _per_page => 3, >+ firstname => 'Manuel', >+ surname => 'Cohen Arazi' >+ }; >+ my ( $filtered_params, $reserved_params ) = $c->extract_reserved_params($input); >+ $c->render( >+ json => { >+ filtered_params => $filtered_params, >+ reserved_params => $reserved_params >+ }, >+ status => 200 >+ ); >+}; >+ >+# The tests >+ >+use Test::More tests => 1; >+use Test::Mojo; >+ >+subtest 'extract_reserved_params() tests' => sub { >+ >+ plan tests => 8; >+ >+ my $t = Test::Mojo->new; >+ >+ $t->get_ok('/query')->status_is(200) >+ ->json_is( '/filtered_params' => >+ { firstname => 'Manuel', surname => 'Cohen Arazi' } ) >+ ->json_is( '/reserved_params' => { _page => 2, _per_page => 3 } ); >+ >+ $t->get_ok('/query_full')->status_is(200) >+ ->json_is( >+ '/filtered_params' => { >+ firstname => 'Manuel', >+ surname => 'Cohen Arazi' >+ } ) >+ ->json_is( >+ '/reserved_params' => { >+ _page => 2, >+ _per_page => 3, >+ _match => 'exact', >+ _order_by => 'blah' >+ } ); >+ >+}; >-- >2.7.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 19234
:
66752
|
66753
|
66754
|
66991
|
66992
|
66993
|
67358
|
67359
|
67360
|
67363
|
67364
|
67365
|
67374
|
67375
|
67377
|
67785
|
67786
|
67787
|
69360
|
69361
|
69362