Add strict/warnings test, adjust all offenders (wow, that was a lot)
[dbsrgits/DBIx-Class.git] / t / cdbi / 30-pager.t
1 use strict;
2 use warnings;
3 use Test::More;
4
5 use lib 't/cdbi/testlib';
6 use Film;
7
8 my @film  = (
9   Film->create({ Title => 'Film 1' }),
10   Film->create({ Title => 'Film 2' }),
11   Film->create({ Title => 'Film 3' }),
12   Film->create({ Title => 'Film 4' }),
13   Film->create({ Title => 'Film 5' }),
14 );
15
16 # first page
17 my ( $pager, $it ) = Film->page(
18     {},
19     { rows => 3,
20       page => 1 }
21 );
22
23 is( $pager->entries_on_this_page, 3, "entries_on_this_page ok" );
24
25 is( $pager->next_page, 2, "next_page ok" );
26
27 is( $it->next->title, "Film 1", "iterator->next ok" );
28
29 $it->next;
30 $it->next;
31
32 is( $it->next, undef, "next past end of page ok" );
33
34 # second page
35 ( $pager, $it ) = Film->page(
36     {},
37     { rows => 3,
38       page => 2 }
39 );
40
41 is( $pager->entries_on_this_page, 2, "entries on second page ok" );
42
43 is( $it->next->title, "Film 4", "second page first title ok" );
44
45 done_testing;