Switch the main dev branch back to 'master'
[dbsrgits/DBIx-Class.git] / t / cdbi / 30-pager.t
CommitLineData
83eef562 1use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat';
2
50891152 3use strict;
4a233f30 4use warnings;
83eef562 5
50891152 6use Test::More;
7
50891152 8use lib 't/cdbi/testlib';
9use Film;
10
11my @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
20my ( $pager, $it ) = Film->page(
21 {},
22 { rows => 3,
23 page => 1 }
24);
25
26is( $pager->entries_on_this_page, 3, "entries_on_this_page ok" );
27
28is( $pager->next_page, 2, "next_page ok" );
29
30is( $it->next->title, "Film 1", "iterator->next ok" );
31
32$it->next;
33$it->next;
34
35is( $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
44is( $pager->entries_on_this_page, 2, "entries on second page ok" );
45
46is( $it->next->title, "Film 4", "second page first title ok" );
d9bd5195 47
48done_testing;