Switch CDBICompat and its tests to OptDeps
[dbsrgits/DBIx-Class-Historic.git] / t / cdbi / 30-pager.t
1 use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat';
2
3 use strict;
4 use warnings;
5
6 use Test::More;
7
8 use lib 't/cdbi/testlib';
9 use Film;
10
11 my @film  = (
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' }),
17 );
18
19 # first page
20 my ( $pager, $it ) = Film->page(
21     {},
22     { rows => 3,
23       page => 1 }
24 );
25
26 is( $pager->entries_on_this_page, 3, "entries_on_this_page ok" );
27
28 is( $pager->next_page, 2, "next_page ok" );
29
30 is( $it->next->title, "Film 1", "iterator->next ok" );
31
32 $it->next;
33 $it->next;
34
35 is( $it->next, undef, "next past end of page ok" );
36
37 # second page
38 ( $pager, $it ) = Film->page(
39     {},
40     { rows => 3,
41       page => 2 }
42 );
43
44 is( $pager->entries_on_this_page, 2, "entries on second page ok" );
45
46 is( $it->next->title, "Film 4", "second page first title ok" );
47
48 done_testing;