Commit | Line | Data |
2a21de92 |
1 | use strict;\r |
2 | use Test::More;\r |
3 | \r |
4 | BEGIN {\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 |
14 | use lib 't/testlib';\r |
15 | use Film;\r |
16 | \r |
17 | my @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 |
26 | my ( $pager, $it ) = Film->page(\r |
27 | {},\r |
28 | { rows => 3,\r |
29 | page => 1 }\r |
30 | );\r |
31 | \r |
32 | is( $pager->entries_on_this_page, 3, "entries_on_this_page ok" );\r |
33 | \r |
34 | is( $pager->next_page, 2, "next_page ok" );\r |
35 | \r |
36 | is( $it->next->title, "Film 1", "iterator->next ok" );\r |
37 | \r |
38 | $it->next;\r |
39 | $it->next;\r |
40 | \r |
41 | is( $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 |
50 | is( $pager->entries_on_this_page, 2, "entries on second page ok" );\r |
51 | \r |
52 | is( $it->next->title, "Film 4", "second page first title ok" );\r |