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>
-use Test::More tests => 16;
+use Test::More tests => 15;
use Test::Warn;
use Koha::Authority::Types;
use Test::Warn;
use Koha::Authority::Types;
is( Koha::Cities->search( { city_country => 'UK' } )->count, 0, 'Koha::Objects->update should have updated the 3 rows' );
};
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;
subtest 'reset' => sub {
plan tests => 3;
$schema->storage->txn_rollback;
$schema->storage->txn_rollback;
-subtest '->is_paged tests' => sub {
+subtest '->is_paged and ->pager tests' => sub {
$schema->storage->txn_begin;
$schema->storage->txn_begin;
+ # Delete existing patrons
+ Koha::Patrons->search->delete;
+ # Create 10 patrons
foreach (1..10) {
$builder->build_object({ class => 'Koha::Patrons' });
}
foreach (1..10) {
$builder->build_object({ class => 'Koha::Patrons' });
}
my $patrons = Koha::Patrons->search();
my $patrons = Koha::Patrons->search();
+ is( $patrons->count, 10, 'Search returns all patrons' );
ok( !$patrons->is_paged, 'Search is not paged' );
ok( !$patrons->is_paged, 'Search is not paged' );
$patrons = Koha::Patrons->search( undef, { 'page' => 1, 'rows' => 3 } );
$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' );
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;
}
$schema->storage->txn_rollback;
}