use strict;
-use warnings;
+use warnings;
use Test::More;
use lib qw(t/lib);
my $schema = DBICTest->init_schema();
-plan tests => 13;
-
# first page
my $it = $schema->resultset("CD")->search(
{},
is( $it->count, 3, "count on paged rs ok" );
+is( $it->pager->total_entries, 5, "total_entries ok" );
+
is( $it->next->title, "Caterwaulin' Blues", "iterator->next ok" );
$it->next;
)->search( undef, { order_by => 'title' } );
is( $it->count, 2, "chained searches paging ok" );
+
+my $p = sub { $schema->resultset("CD")->page(1)->pager->entries_per_page; };
+
+is($p->(), 10, 'default rows is 10');
+
+$schema->default_resultset_attributes({ rows => 5 });
+
+is($p->(), 5, 'default rows is 5');
+
+# test page with offset
+$it = $schema->resultset('CD')->search({}, {
+ rows => 2,
+ page => 2,
+ offset => 1,
+ order_by => 'cdid'
+});
+
+my $row = $schema->resultset('CD')->search({}, {
+ order_by => 'cdid',
+ offset => 3,
+ rows => 1
+})->single;
+
+is($row->cdid, $it->first->cdid, 'page with offset');
+
+done_testing;