Introduce GOVERNANCE document and empty RESOLUTIONS file.
[dbsrgits/DBIx-Class.git] / t / cdbi / 30-pager.t
1 BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
2 use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat';
3
4 use strict;
5 use warnings;
6
7 use Test::More;
8
9 use lib 't/cdbi/testlib';
10 use Film;
11
12 my @film  = (
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' }),
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
39 ( $pager, $it ) = Film->page(
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" );
48
49 done_testing;