Browse Source

Bug 19209: (QA followup) Improve tests

This path merges the pager() test and adds search results count tests

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
17.11.x
Tomás Cohen Arazi 7 years ago
committed by Jonathan Druart
parent
commit
8c90bb78c9
  1. 23
      t/db_dependent/Koha/Objects.t

23
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;
}

Loading…
Cancel
Save