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