Reorganize CDBICompat tests - centralize prereq checks in one place
[dbsrgits/DBIx-Class.git] / t / cdbi / 30-pager.t
CommitLineData
50891152 1use strict;
2use Test::More;
3
50891152 4use lib 't/cdbi/testlib';
5use Film;
6
7my @film = (
6a3bf251 8 Film->create({ Title => 'Film 1' }),
9 Film->create({ Title => 'Film 2' }),
10 Film->create({ Title => 'Film 3' }),
11 Film->create({ Title => 'Film 4' }),
12 Film->create({ Title => 'Film 5' }),
50891152 13);
14
15# first page
16my ( $pager, $it ) = Film->page(
17 {},
18 { rows => 3,
19 page => 1 }
20);
21
22is( $pager->entries_on_this_page, 3, "entries_on_this_page ok" );
23
24is( $pager->next_page, 2, "next_page ok" );
25
26is( $it->next->title, "Film 1", "iterator->next ok" );
27
28$it->next;
29$it->next;
30
31is( $it->next, undef, "next past end of page ok" );
32
33# second page
8273e845 34( $pager, $it ) = Film->page(
50891152 35 {},
36 { rows => 3,
37 page => 2 }
38);
39
40is( $pager->entries_on_this_page, 2, "entries on second page ok" );
41
42is( $it->next->title, "Film 4", "second page first title ok" );
d9bd5195 43
44done_testing;