Introduce GOVERNANCE document and empty RESOLUTIONS file.
[dbsrgits/DBIx-Class.git] / t / cdbi / 30-pager.t
CommitLineData
c0329273 1BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
83eef562 2use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat';
3
50891152 4use strict;
4a233f30 5use warnings;
83eef562 6
50891152 7use Test::More;
8
50891152 9use lib 't/cdbi/testlib';
10use Film;
11
12my @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
21my ( $pager, $it ) = Film->page(
22 {},
23 { rows => 3,
24 page => 1 }
25);
26
27is( $pager->entries_on_this_page, 3, "entries_on_this_page ok" );
28
29is( $pager->next_page, 2, "next_page ok" );
30
31is( $it->next->title, "Film 1", "iterator->next ok" );
32
33$it->next;
34$it->next;
35
36is( $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
45is( $pager->entries_on_this_page, 2, "entries on second page ok" );
46
47is( $it->next->title, "Film 4", "second page first title ok" );
d9bd5195 48
49done_testing;