From 7abe6e9670ecb9b879e3b8c237fd9fad35f5ff18 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 30 Aug 2017 12:09:37 -0300 Subject: [PATCH] Bug 19209: Add ->is_paged method to Koha::Objects This patch adds ->is_paged to Koha::Objects. It is inherited from the underlying resultset from DBIC so there's no code besides adding it to the known methods in AUTOLOAD. Tests are added for the newly exported method. To test: - Apply this patch - Run: $ sudo koha-shell kohadev k$ cd kohaclone k$ prove t/db_dependent/Koha/Objects.t => SUCCESS: Tests pass! - Sign off :-D Sponsored-by: Camden County Signed-off-by: Kyle M Hall Signed-off-by: Marcel de Rooy Signed-off-by: Jonathan Druart --- Koha/Objects.pm | 2 +- t/db_dependent/Koha/Objects.t | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Koha/Objects.pm b/Koha/Objects.pm index 193e494a4c..8c79afda1a 100644 --- a/Koha/Objects.pm +++ b/Koha/Objects.pm @@ -379,7 +379,7 @@ Currently count, pager, update and delete are covered. sub AUTOLOAD { my ( $self, @params ) = @_; - my @known_methods = qw( count pager update delete result_class single slice ); + my @known_methods = qw( count is_paged pager update delete result_class single slice ); my $method = our $AUTOLOAD; $method =~ s/.*:://; diff --git a/t/db_dependent/Koha/Objects.t b/t/db_dependent/Koha/Objects.t index c05afc3f2d..b382ce1f85 100644 --- a/t/db_dependent/Koha/Objects.t +++ b/t/db_dependent/Koha/Objects.t @@ -19,7 +19,7 @@ use Modern::Perl; -use Test::More tests => 15; +use Test::More tests => 16; use Test::Warn; use Koha::Authority::Types; @@ -214,3 +214,21 @@ subtest 'Exceptions' => sub { }; $schema->storage->txn_rollback; + +subtest '->is_paged tests' => sub { + + plan tests => 2; + + $schema->storage->txn_begin; + + foreach (1..10) { + $builder->build_object({ class => 'Koha::Patrons' }); + } + + my $patrons = Koha::Patrons->search(); + ok( !$patrons->is_paged, 'Search is not paged' ); + $patrons = Koha::Patrons->search( undef, { 'page' => 1, 'rows' => 3 } ); + ok( $patrons->is_paged, 'Search is paged' ); + + $schema->storage->txn_rollback; +} -- 2.39.5