Commit | Line | Data |
59f8e584 |
1 | use Test::More; |
2 | |
3 | plan tests => 8; |
4 | |
5 | use lib qw(t/lib); |
6 | |
7 | use_ok('DBICTest'); |
8 | |
9 | # first page |
2a21de92 |
10 | my $it = DBICTest::CD->search( |
59f8e584 |
11 | {}, |
12 | { order_by => 'title', |
13 | rows => 3, |
14 | page => 1 } |
15 | ); |
2a21de92 |
16 | my $pager = DBICTest::CD->page; |
17 | |
59f8e584 |
18 | is( $pager->entries_on_this_page, 3, "entries_on_this_page ok" ); |
19 | |
20 | is( $pager->next_page, 2, "next_page ok" ); |
21 | |
22 | is( $it->next->title, "Caterwaulin' Blues", "iterator->next ok" ); |
23 | |
24 | $it->next; |
25 | $it->next; |
26 | |
27 | is( $it->next, undef, "next past end of page ok" ); |
28 | |
2a21de92 |
29 | # second page, testing with array |
30 | my @page2 = DBICTest::CD->search( |
59f8e584 |
31 | {}, |
32 | { order_by => 'title', |
33 | rows => 3, |
34 | page => 2 } |
35 | ); |
2a21de92 |
36 | $pager = DBICTest::CD->page; |
59f8e584 |
37 | |
38 | is( $pager->entries_on_this_page, 2, "entries on second page ok" ); |
39 | |
2a21de92 |
40 | is( $page2[0]->title, "Generic Manufactured Singles", "second page first title ok" ); |
59f8e584 |
41 | |
42 | # based on a failing criteria submitted by waswas |
43 | # requires SQL::Abstract >= 1.20 |
2a21de92 |
44 | $it = DBICTest::CD->search( |
59f8e584 |
45 | { title => [ |
46 | -and => |
47 | { |
48 | -like => '%bees' |
49 | }, |
50 | { |
51 | -not_like => 'Forkful%' |
52 | } |
53 | ] |
54 | }, |
55 | { rows => 5 } |
56 | ); |
57 | is( $it->count, 1, "complex abstract count ok" ); |