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