Massive cleanup of DateTime test dependencies, other interim
[dbsrgits/DBIx-Class.git] / t / cdbi / 30-pager.t
CommitLineData
50891152 1use strict;
2use Test::More;
3
4BEGIN {
5 eval "use DBIx::Class::CDBICompat;";
6 if ($@) {
7 plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required');
50891152 8 }
68de9438 9 plan tests => 6;
50891152 10}
11
12use lib 't/cdbi/testlib';
13use Film;
14
15my @film = (
6a3bf251 16 Film->create({ Title => 'Film 1' }),
17 Film->create({ Title => 'Film 2' }),
18 Film->create({ Title => 'Film 3' }),
19 Film->create({ Title => 'Film 4' }),
20 Film->create({ Title => 'Film 5' }),
50891152 21);
22
23# first page
24my ( $pager, $it ) = Film->page(
25 {},
26 { rows => 3,
27 page => 1 }
28);
29
30is( $pager->entries_on_this_page, 3, "entries_on_this_page ok" );
31
32is( $pager->next_page, 2, "next_page ok" );
33
34is( $it->next->title, "Film 1", "iterator->next ok" );
35
36$it->next;
37$it->next;
38
39is( $it->next, undef, "next past end of page ok" );
40
41# second page
42( $pager, $it ) = Film->page(
43 {},
44 { rows => 3,
45 page => 2 }
46);
47
48is( $pager->entries_on_this_page, 2, "entries on second page ok" );
49
50is( $it->next->title, "Film 4", "second page first title ok" );