Commit | Line | Data |
0567538f |
1 | sub run_tests { |
2 | |
3 | plan tests => 12; |
4 | |
5 | # first page |
3712e4f4 |
6 | my $it = DBICTest->class("CD")->search( |
0567538f |
7 | {}, |
8 | { order_by => 'title', |
9 | rows => 3, |
10 | page => 1 } |
11 | ); |
12 | |
13 | is( $it->pager->entries_on_this_page, 3, "entries_on_this_page ok" ); |
14 | |
15 | is( $it->pager->next_page, 2, "next_page ok" ); |
16 | |
17 | is( $it->count, 3, "count on paged rs ok" ); |
18 | |
19 | is( $it->next->title, "Caterwaulin' Blues", "iterator->next ok" ); |
20 | |
21 | $it->next; |
22 | $it->next; |
23 | |
24 | is( $it->next, undef, "next past end of page ok" ); |
25 | |
26 | # second page, testing with array |
3712e4f4 |
27 | my @page2 = DBICTest->class("CD")->search( |
0567538f |
28 | {}, |
29 | { order_by => 'title', |
30 | rows => 3, |
31 | page => 2 } |
32 | ); |
33 | |
34 | is( $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 | ); |
42 | my $page = $it->page(2); |
43 | |
44 | is( $page->count, 2, "standard resultset paged rs count ok" ); |
45 | |
46 | is( $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 | ); |
56 | is( $it->pager->entries_on_this_page, 2, "software entries_on_this_page ok" ); |
57 | |
58 | is( $it->pager->previous_page, 1, "software previous_page ok" ); |
59 | |
60 | is( $it->count, 2, "software count on paged rs ok" ); |
61 | |
62 | is( $it->next->title, "Generic Manufactured Singles", "software iterator->next ok" ); |
63 | |
64 | } |
65 | |
66 | 1; |