From 599bb346216d5988e3933f7806a7ceb5542bdd12 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 30 Aug 2017 12:30:05 -0300 Subject: [PATCH] Bug 19209: (QA followup) Improve tests This path merges the pager() test and adds search results count tests Signed-off-by: Tomas Cohen Arazi --- t/db_dependent/Koha/Objects.t | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/t/db_dependent/Koha/Objects.t b/t/db_dependent/Koha/Objects.t index b382ce1..069c2c8 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 => 16; +use Test::More tests => 15; use Test::Warn; use Koha::Authority::Types; @@ -74,12 +74,6 @@ subtest 'update' => sub { is( Koha::Cities->search( { city_country => 'UK' } )->count, 0, 'Koha::Objects->update should have updated the 3 rows' ); }; -subtest 'pager' => sub { - plan tests => 1; - my $pager = Koha::Patrons->search( {}, { page => 1, rows => 2 } )->pager; - is( ref($pager), 'DBIx::Class::ResultSet::Pager', 'Koha::Objects->pager returns a valid DBIx::Class object' ); -}; - subtest 'reset' => sub { plan tests => 3; @@ -215,20 +209,31 @@ subtest 'Exceptions' => sub { $schema->storage->txn_rollback; -subtest '->is_paged tests' => sub { +subtest '->is_paged and ->pager tests' => sub { - plan tests => 2; + plan tests => 5; $schema->storage->txn_begin; + # Delete existing patrons + Koha::Patrons->search->delete; + # Create 10 patrons foreach (1..10) { $builder->build_object({ class => 'Koha::Patrons' }); } + # Non-paginated search my $patrons = Koha::Patrons->search(); + is( $patrons->count, 10, 'Search returns all patrons' ); ok( !$patrons->is_paged, 'Search is not paged' ); + + # Paginated search $patrons = Koha::Patrons->search( undef, { 'page' => 1, 'rows' => 3 } ); + is( $patrons->count, 3, 'Search returns only one page, 3 patrons' ); ok( $patrons->is_paged, 'Search is paged' ); + my $pager = $patrons->pager; + is( ref($patrons->pager), 'DBIx::Class::ResultSet::Pager', + 'Koha::Objects->pager returns a valid DBIx::Class object' ); $schema->storage->txn_rollback; } -- 2.7.4