4 use Test::More qw(no_plan);
8 my $schema = DBICTest->init_schema();
11 my $it = $schema->resultset("CD")->search(
13 { order_by => 'title',
18 is( $it->pager->entries_on_this_page, 3, "entries_on_this_page ok" );
20 is( $it->pager->next_page, 2, "next_page ok" );
22 is( $it->count, 3, "count on paged rs ok" );
24 is( $it->next->title, "Caterwaulin' Blues", "iterator->next ok" );
29 is( $it->next, undef, "next past end of page ok" );
31 # second page, testing with array
32 my @page2 = $schema->resultset("CD")->search(
34 { order_by => 'title',
39 is( $page2[0]->title, "Generic Manufactured Singles", "second page first title ok" );
41 # page a standard resultset
42 $it = $schema->resultset("CD")->search(
44 { order_by => 'title',
47 my $page = $it->page(2);
49 is( $page->count, 2, "standard resultset paged rs count ok" );
51 is( $page->next->title, "Generic Manufactured Singles", "second page of standard resultset ok" );
53 # test software-based limit paging
54 $it = $schema->resultset("CD")->search(
56 { order_by => 'title',
61 is( $it->pager->entries_on_this_page, 2, "software entries_on_this_page ok" );
63 is( $it->pager->previous_page, 1, "software previous_page ok" );
65 is( $it->count, 2, "software count on paged rs ok" );
67 is( $it->next->title, "Generic Manufactured Singles", "software iterator->next ok" );
69 # test paging with chained searches
70 $it = $schema->resultset("CD")->search(
74 )->search( undef, { order_by => 'title' } );
76 is( $it->count, 2, "chained searches paging ok" );
78 my $p = sub { $schema->resultset("CD")->page(1)->pager->entries_per_page; };
80 is($p->(), 10, 'default rows is 10');
82 $schema->default_resultset_attributes({ rows => 5 });
84 is($p->(), 5, 'default rows is 5');