Bugzilla – Attachment 69366 Details for
Bug 19278
Add a configurable default page size for endpoints
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19278: Unit tests
Bug-19278-Unit-tests.patch (text/plain), 3.50 KB, created by
Kyle M Hall (khall)
on 2017-11-27 11:37:31 UTC
(
hide
)
Description:
Bug 19278: Unit tests
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2017-11-27 11:37:31 UTC
Size:
3.50 KB
patch
obsolete
>From eeaadcf833d45b8bce0c1a9659de93edce1e036e Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 8 Sep 2017 12:18:35 -0300 >Subject: [PATCH] Bug 19278: Unit tests > >This patch introduces tests for a behaviour change in >Koha::REST::Plugin::Pagination. > >To test: >- Run: > $ sudo koha-shell kohadev > k$ cd kohaclone > k$ prove t/Koha/REST/Plugin/Pagination.t >=> FAIL: Tests should fail without the followup patch applied > >Sponsored-by: Camden County >Sponsored-by: Bywater Solutions > >Signed-off-by: Lari Taskula <lari.taskula@jns.fi> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > t/Koha/REST/Plugin/Pagination.t | 40 +++++++++++++++++++++++++++++++++++++++- > 1 file changed, 39 insertions(+), 1 deletion(-) > >diff --git a/t/Koha/REST/Plugin/Pagination.t b/t/Koha/REST/Plugin/Pagination.t >index 37cf0ca..43e9f07 100644 >--- a/t/Koha/REST/Plugin/Pagination.t >+++ b/t/Koha/REST/Plugin/Pagination.t >@@ -58,14 +58,28 @@ get '/dbic_merge_pagination' => sub { > $c->render( json => $filter, status => 200 ); > }; > >+get '/pagination_headers_without_page_size' => sub { >+ my $c = shift; >+ $c->add_pagination_headers({ total => 10, params => { _page => 2, firstname => 'Jonathan' } }); >+ $c->render( json => { ok => 1 }, status => 200 ); >+}; >+ >+get '/pagination_headers_without_page' => sub { >+ my $c = shift; >+ $c->add_pagination_headers({ total => 10, params => { _per_page => 4, firstname => 'Jonathan' } }); >+ $c->render( json => { ok => 1 }, status => 200 ); >+}; >+ > # The tests > > use Test::More tests => 2; > use Test::Mojo; > >+use t::lib::Mocks; >+ > subtest 'add_pagination_headers() tests' => sub { > >- plan tests => 45; >+ plan tests => 64; > > my $t = Test::Mojo->new; > >@@ -117,6 +131,30 @@ subtest 'add_pagination_headers() tests' => sub { > ->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::lib::Mocks::mock_preference('RESTdefaultPageSize', 3); >+ $t->get_ok('/pagination_headers_without_page_size') >+ ->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_without_page') >+ ->status_is( 200 ) >+ ->header_is( 'X-Total-Count' => undef, 'X-Total-Count header absent' ) >+ ->header_is( 'Link' => undef, 'Link header absent' ); >+ >+ > }; > > subtest 'dbic_merge_pagination() tests' => sub { >-- >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 19278
:
66994
|
66995
|
66996
|
67341
|
67604
|
67605
|
67606
|
67607
|
67700
|
67701
|
67702
|
67703
|
67790
|
67791
|
67792
|
67793
|
69365
| 69366 |
69367
|
69368
|
69704