Bugzilla – Attachment 66609 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), 4.16 KB, created by
Tomás Cohen Arazi (tcohen)
on 2017-08-30 12:24:32 UTC
(
hide
)
Description:
Bug 19196: Unit tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2017-08-30 12:24:32 UTC
Size:
4.16 KB
patch
obsolete
>From d94a92f3bfe89a83a7bd4be148b6d57293626d90 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 >--- > t/Koha/REST/Plugin/Pagination.t | 108 ++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 108 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 0000000000..96ccc7607d >--- /dev/null >+++ b/t/Koha/REST/Plugin/Pagination.t >@@ -0,0 +1,108 @@ >+#!/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 '/total_count_header' => sub { >+ my $c = shift; >+ $c->total_count_header({ total => 100 }); >+ $c->render( json => { ok => 1 }, status => 200 ); >+}; >+ >+get '/links_header' => sub { >+ my $c = shift; >+ $c->links_header({ total => 10, page => 2, per_page => 3 }); >+ $c->render( json => { ok => 1 }, status => 200 ); >+}; >+ >+get '/links_header_first_page' => sub { >+ my $c = shift; >+ $c->links_header({ total => 10, page => 1, per_page => 3 }); >+ $c->render( json => { ok => 1 }, status => 200 ); >+}; >+ >+get '/links_header_last_page' => sub { >+ my $c = shift; >+ $c->links_header({ total => 10, page => 4, per_page => 3 }); >+ $c->render( json => { ok => 1 }, status => 200 ); >+}; >+ >+# The tests >+ >+use Test::More tests => 2; >+use Test::Mojo; >+ >+subtest 'total_count_header() tests' => sub { >+ >+ plan tests => 6; >+ >+ my $t = Test::Mojo->new; >+ >+ $t->get_ok('/empty') >+ ->status_is( 200 ) >+ ->header_is( 'X-Total-Count' => undef, 'X-Total-Count is undefined' ); >+ >+ $t->get_ok('/total_count_header') >+ ->status_is( 200 ) >+ ->header_is( 'X-Total-Count' => 100, 'X-Total-Count contains the hardcoded value' ); >+ >+}; >+ >+subtest 'links_header() tests' => sub { >+ >+ plan tests => 21; >+ >+ my $t = Test::Mojo->new; >+ >+ $t->get_ok('/empty') >+ ->status_is( 200 ) >+ ->header_is( 'Link' => undef, 'Link is undefined' ); >+ >+ $t->get_ok('/links_header') >+ ->status_is( 200 ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?per_page=3&page=1>; rel="prev",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?per_page=3&page=3>; rel="next",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?per_page=3&page=1>; rel="first",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?per_page=3&page=4>; rel="last"/ ); >+ >+ $t->get_ok('/links_header_first_page') >+ ->status_is( 200 ) >+ ->header_unlike( 'Link' => qr/<http:\/\/.*\?per_page=3&page=.*>; rel="prev",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?per_page=3&page=2>; rel="next",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?per_page=3&page=1>; rel="first",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?per_page=3&page=4>; rel="last"/ ); >+ >+ $t->get_ok('/links_header_last_page') >+ ->status_is( 200 ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?per_page=3&page=3>; rel="prev",/ ) >+ ->header_unlike( 'Link' => qr/<http:\/\/.*\?per_page=3&page=.*>; rel="next",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?per_page=3&page=1>; rel="first",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?per_page=3&page=4>; rel="last"/ ); >+}; >-- >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 19196
:
66599
|
66600
|
66601
|
66609
|
66610
|
66611
|
66656
|
66657
|
66658
|
66820
|
66821
|
66822
|
66988
|
66989
|
66990
|
67338
|
67339
|
67340
|
67346
|
67366
|
67367
|
67368
|
67369