Bugzilla – Attachment 66988 Details for
Bug 19196
Add pagination helpers
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19196: Unit tests
Bug-19196-Unit-tests.patch (text/plain), 5.77 KB, created by
Kyle M Hall (khall)
on 2017-09-08 14:00:01 UTC
(
hide
)
Description:
Bug 19196: Unit tests
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2017-09-08 14:00:01 UTC
Size:
5.77 KB
patch
obsolete
>From 86befb455ae9c39ebdba0e6a217bc41a1a7bd5a6 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Tue, 29 Aug 2017 17:00:50 -0300 >Subject: [PATCH] Bug 19196: Unit tests > >This patch adds unit tests for the new pagination Mojo plugin. > >Sponsored-by: ByWater Solutions >Sponsored-by: Camden County > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > t/Koha/REST/Plugin/Pagination.t | 110 ++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 110 insertions(+) > create mode 100644 t/Koha/REST/Plugin/Pagination.t > >diff --git a/t/Koha/REST/Plugin/Pagination.t b/t/Koha/REST/Plugin/Pagination.t >new file mode 100644 >index 0000000..04d51e1 >--- /dev/null >+++ b/t/Koha/REST/Plugin/Pagination.t >@@ -0,0 +1,110 @@ >+#!/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::Pagination'; >+ >+ >+get '/empty' => sub { >+ my $c = shift; >+ $c->render( json => { ok => 1 }, status => 200 ); >+}; >+ >+get '/pagination_headers' => sub { >+ my $c = shift; >+ $c->add_pagination_headers({ total => 10, params => { page => 2, per_page => 3, firstname => 'Jonathan' } }); >+ $c->render( json => { ok => 1 }, status => 200 ); >+}; >+ >+get '/pagination_headers_first_page' => sub { >+ my $c = shift; >+ $c->add_pagination_headers({ total => 10, params => { page => 1, per_page => 3, firstname => 'Jonathan' } }); >+ $c->render( json => { ok => 1 }, status => 200 ); >+}; >+ >+get '/pagination_headers_last_page' => sub { >+ my $c = shift; >+ $c->add_pagination_headers({ total => 10, params => { page => 4, per_page => 3, firstname => 'Jonathan' } }); >+ $c->render( json => { ok => 1 }, status => 200 ); >+}; >+ >+# The tests >+ >+use Test::More tests => 1; >+use Test::Mojo; >+ >+subtest 'add_pagination_headers() tests' => sub { >+ >+ plan tests => 45; >+ >+ my $t = Test::Mojo->new; >+ >+ $t->get_ok('/empty') >+ ->status_is( 200 ) >+ ->header_is( 'X-Total-Count' => undef, 'X-Total-Count is undefined' ) >+ ->header_is( 'Link' => undef, 'Link is undefined' ); >+ >+ $t->get_ok('/pagination_headers') >+ ->status_is( 200 ) >+ ->header_is( 'X-Total-Count' => 10, 'X-Total-Count contains the passed value' ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*per_page=3.*>; rel="prev",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*page=1.*>; rel="prev",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*firstname=Jonathan.*>; rel="prev",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*per_page=3.*>; rel="next",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*page=3.*>; rel="next",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*firstname=Jonathan.*>; rel="next",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*per_page=3.*>; rel="first",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*page=1.*>; rel="first",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*firstname=Jonathan.*>; rel="first",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*per_page=3.*>; rel="last"/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*page=4.*>; rel="last"/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*firstname=Jonathan.*>; rel="last"/ ); >+ >+ $t->get_ok('/pagination_headers_first_page') >+ ->status_is( 200 ) >+ ->header_is( 'X-Total-Count' => 10, 'X-Total-Count contains the passed value' ) >+ ->header_unlike( 'Link' => qr/<http:\/\/.*\?.*>; rel="prev",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*per_page=3.*>; rel="next",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*page=2.*>; rel="next",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*firstname=Jonathan.*>; rel="next",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*per_page=3.*>; rel="first",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*page=1.*>; rel="first",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*firstname=Jonathan.*>; rel="first",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*per_page=3.*>; rel="last"/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*page=4.*>; rel="last"/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*firstname=Jonathan.*>; rel="last"/ ); >+ >+ $t->get_ok('/pagination_headers_last_page') >+ ->status_is( 200 ) >+ ->header_is( 'X-Total-Count' => 10, 'X-Total-Count contains the passed value' ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*per_page=3.*>; rel="prev",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*page=3.*>; rel="prev",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*firstname=Jonathan.*>; rel="prev",/ ) >+ ->header_unlike( 'Link' => qr/<http:\/\/.*\?.*>; rel="next",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*per_page=3.*>; rel="first",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*page=1.*>; rel="first",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*firstname=Jonathan.*>; rel="first",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*per_page=3.*>; rel="last"/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*page=4.*>; rel="last"/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*firstname=Jonathan.*>; rel="last"/ ); >+}; >-- >2.10.2
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 19196
:
66599
|
66600
|
66601
|
66609
|
66610
|
66611
|
66656
|
66657
|
66658
|
66820
|
66821
|
66822
|
66988
|
66989
|
66990
|
67338
|
67339
|
67340
|
67346
|
67366
|
67367
|
67368
|
67369