Commit | Line | Data |
59f8e584 |
1 | use Test::More; |
2 | |
3 | plan tests => 8; |
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 | |
48 | is( $page->next->title, "Generic Manufactured Singles", "second page of standard resultset ok" ); |