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