Bugzilla – Attachment 66752 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), 2.98 KB, created by
Tomás Cohen Arazi (tcohen)
on 2017-09-01 15:02:32 UTC
(
hide
)
Description:
Bug 19234: Unit tests for query parameters handling helpers
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2017-09-01 15:02:32 UTC
Size:
2.98 KB
patch
obsolete
>From 6727dc8928f1f03ca6233a8a1f0fb6185c2236b3 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 >--- > t/Koha/REST/Plugin/Query.t | 82 ++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 82 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 0000000000..84b2038788 >--- /dev/null >+++ b/t/Koha/REST/Plugin/Query.t >@@ -0,0 +1,82 @@ >+#!/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 ( $filter, $attributes ) = $c->generate_dbic_query($input); >+ $c->render( json => { filter => $filter, attributes => $attributes }, status => 200 ); >+}; >+ >+get '/query_exact' => sub { >+ my $c = shift; >+ my $input = { >+ page => 2, >+ per_page => 3, >+ firstname => 'Manuel', >+ surname => 'Cohen Arazi', >+ _exact_match => 1 >+ }; >+ my ( $filter, $attributes ) = $c->generate_dbic_query($input); >+ $c->render( json => { filter => $filter, attributes => $attributes }, status => 200 ); >+}; >+ >+# The tests >+ >+use Test::More tests => 1; >+use Test::Mojo; >+ >+subtest 'generate_dbic_query() tests' => sub { >+ >+ plan tests => 8; >+ >+ my $t = Test::Mojo->new; >+ >+ $t->get_ok('/query') >+ ->status_is( 200 ) >+ ->json_is( '/attributes' => { page => 2, rows => 3 } ) >+ ->json_is( '/filter' => { firstname => { like => 'Manuel%' }, surname => { like => 'Cohen Arazi%' } } ); >+ >+ $t->get_ok('/query_exact') >+ ->status_is( 200 ) >+ ->json_is( '/attributes' => { page => 2, rows => 3 } ) >+ ->json_is( '/filter' => { firstname => 'Manuel' , surname => 'Cohen Arazi' } ); >+ >+ # use Data::Printer colored => 1; >+ # p($t->tx->res); >+}; >+ >-- >2.14.1
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