From 43fe61ca05e773bc557cbe2dd85abb33e753d50b Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 26 Sep 2017 15:11:38 -0300 Subject: [PATCH] Bug 19369: Unit tests --- t/Koha/REST/Plugin/Pagination.t | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/t/Koha/REST/Plugin/Pagination.t b/t/Koha/REST/Plugin/Pagination.t index 586b373..45f1bd8 100644 --- a/t/Koha/REST/Plugin/Pagination.t +++ b/t/Koha/REST/Plugin/Pagination.t @@ -24,6 +24,7 @@ app->log->level('error'); plugin 'Koha::REST::Plugin::Pagination'; +# For add_pagination_headers() get '/empty' => sub { my $c = shift; @@ -48,9 +49,18 @@ get '/pagination_headers_last_page' => sub { $c->render( json => { ok => 1 }, status => 200 ); }; +# For dbic_merge_pagination + +get '/dbic_merge_pagination' => sub { + my $c = shift; + my $filter = { firstname => 'Kyle', surname => 'Hall' }; + $filter = $c->dbic_merge_pagination({ filter => $filter, params => { _page => 1, _per_page => 3 } }); + $c->render( json => $filter, status => 200 ); +}; + # The tests -use Test::More tests => 1; +use Test::More tests => 2; use Test::Mojo; subtest 'add_pagination_headers() tests' => sub { @@ -108,3 +118,14 @@ subtest 'add_pagination_headers() tests' => sub { ->header_like( 'Link' => qr/; rel="last"/ ) ->header_like( 'Link' => qr/; rel="last"/ ); }; + +subtest 'dbic_merge_pagination() tests' => sub { + + plan tests => 3; + + my $t = Test::Mojo->new; + + $t->get_ok('/dbic_merge_pagination') + ->status_is(200) + ->json_is({ firstname => 'Kyle', surname => 'Hall', page => 1, rows => 3 }); +}; -- 2.7.4