/
30-pager.t
49 lines (35 loc) · 999 Bytes
/
30-pager.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat';
use strict;
use warnings;
use Test::More;
use lib 't/cdbi/testlib';
use Film;
my @film = (
Film->create({ Title => 'Film 1' }),
Film->create({ Title => 'Film 2' }),
Film->create({ Title => 'Film 3' }),
Film->create({ Title => 'Film 4' }),
Film->create({ Title => 'Film 5' }),
);
# first page
my ( $pager, $it ) = Film->page(
{},
{ rows => 3,
page => 1 }
);
is( $pager->entries_on_this_page, 3, "entries_on_this_page ok" );
is( $pager->next_page, 2, "next_page ok" );
is( $it->next->title, "Film 1", "iterator->next ok" );
$it->next;
$it->next;
is( $it->next, undef, "next past end of page ok" );
# second page
( $pager, $it ) = Film->page(
{},
{ rows => 3,
page => 2 }
);
is( $pager->entries_on_this_page, 2, "entries on second page ok" );
is( $it->next->title, "Film 4", "second page first title ok" );
done_testing;