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