Commit | Line | Data |
50891152 |
1 | use strict; |
2 | use Test::More; |
3 | |
50891152 |
4 | use lib 't/cdbi/testlib'; |
5 | use Film; |
6 | |
7 | my @film = ( |
6a3bf251 |
8 | Film->create({ Title => 'Film 1' }), |
9 | Film->create({ Title => 'Film 2' }), |
10 | Film->create({ Title => 'Film 3' }), |
11 | Film->create({ Title => 'Film 4' }), |
12 | Film->create({ Title => 'Film 5' }), |
50891152 |
13 | ); |
14 | |
15 | # first page |
16 | my ( $pager, $it ) = Film->page( |
17 | {}, |
18 | { rows => 3, |
19 | page => 1 } |
20 | ); |
21 | |
22 | is( $pager->entries_on_this_page, 3, "entries_on_this_page ok" ); |
23 | |
24 | is( $pager->next_page, 2, "next_page ok" ); |
25 | |
26 | is( $it->next->title, "Film 1", "iterator->next ok" ); |
27 | |
28 | $it->next; |
29 | $it->next; |
30 | |
31 | is( $it->next, undef, "next past end of page ok" ); |
32 | |
33 | # second page |
8273e845 |
34 | ( $pager, $it ) = Film->page( |
50891152 |
35 | {}, |
36 | { rows => 3, |
37 | page => 2 } |
38 | ); |
39 | |
40 | is( $pager->entries_on_this_page, 2, "entries on second page ok" ); |
41 | |
42 | is( $it->next->title, "Film 4", "second page first title ok" ); |
d9bd5195 |
43 | |
44 | done_testing; |