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