Release shipped, Changes update and version bumped
[dbsrgits/DBIx-Class.git] / t / run / 07pager.tl
CommitLineData
0567538f 1sub run_tests {
2
3plan tests => 12;
4
5# first page
3712e4f4 6my $it = DBICTest->class("CD")->search(
0567538f 7 {},
8 { order_by => 'title',
9 rows => 3,
10 page => 1 }
11);
12
13is( $it->pager->entries_on_this_page, 3, "entries_on_this_page ok" );
14
15is( $it->pager->next_page, 2, "next_page ok" );
16
17is( $it->count, 3, "count on paged rs ok" );
18
19is( $it->next->title, "Caterwaulin' Blues", "iterator->next ok" );
20
21$it->next;
22$it->next;
23
24is( $it->next, undef, "next past end of page ok" );
25
26# second page, testing with array
3712e4f4 27my @page2 = DBICTest->class("CD")->search(
0567538f 28 {},
29 { order_by => 'title',
30 rows => 3,
31 page => 2 }
32);
33
34is( $page2[0]->title, "Generic Manufactured Singles", "second page first title ok" );
35
36# page a standard resultset
3712e4f4 37$it = DBICTest->class("CD")->search(
0567538f 38 {},
39 { order_by => 'title',
40 rows => 3 }
41);
42my $page = $it->page(2);
43
44is( $page->count, 2, "standard resultset paged rs count ok" );
45
46is( $page->next->title, "Generic Manufactured Singles", "second page of standard resultset ok" );
47
48# test software-based limit paging
3712e4f4 49$it = DBICTest->class("CD")->search(
0567538f 50 {},
51 { order_by => 'title',
52 rows => 3,
53 page => 2,
54 software_limit => 1 }
55);
56is( $it->pager->entries_on_this_page, 2, "software entries_on_this_page ok" );
57
58is( $it->pager->previous_page, 1, "software previous_page ok" );
59
60is( $it->count, 2, "software count on paged rs ok" );
61
62is( $it->next->title, "Generic Manufactured Singles", "software iterator->next ok" );
63
64}
65
661;