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