X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F67pager.t;h=6a6aabc60d1c44e7b7414dcb3670be83ecfd0f07;hb=7eb9a6f1f9b6cd83aaa91e142c001b72b7ccd407;hp=267927d34998e046edd19514a08429145d70b17b;hpb=a47e123334d8bcea0d34dc9ea09738d6f3b1fd49;p=dbsrgits%2FDBIx-Class.git diff --git a/t/67pager.t b/t/67pager.t index 267927d..6a6aabc 100644 --- a/t/67pager.t +++ b/t/67pager.t @@ -1,14 +1,12 @@ use strict; use warnings; -use Test::More; +use Test::More qw(no_plan); use lib qw(t/lib); use DBICTest; my $schema = DBICTest->init_schema(); -plan tests => 12; - # first page my $it = $schema->resultset("CD")->search( {}, @@ -23,6 +21,8 @@ is( $it->pager->next_page, 2, "next_page ok" ); 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; @@ -68,3 +68,35 @@ is( $it->count, 2, "software count on paged rs ok" ); is( $it->next->title, "Generic Manufactured Singles", "software iterator->next ok" ); +# test paging with chained searches +$it = $schema->resultset("CD")->search( + {}, + { rows => 2, + page => 2 } +)->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');