Commit | Line | Data |
4f99ad18 |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use Test::More; |
5 | |
289ba852 |
6 | BEGIN { |
7 | eval "use DBIx::Class::CDBICompat;"; |
8 | if ($@) { |
9 | plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required'); |
10 | next; |
11 | } |
12 | eval "use DBD::SQLite"; |
13 | plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 10); |
14 | } |
4f99ad18 |
15 | |
16 | use lib 't/lib'; |
17 | |
58d387fe |
18 | use_ok('DBICTest'); |
19 | DBICTest::init_schema(); |
4f99ad18 |
20 | |
21 | DBICTest::CD->load_components(qw/CDBICompat::Pager/); |
22 | |
23 | my ( $pager, $it ) = DBICTest::CD->page( |
24 | {}, |
25 | { order_by => 'title', |
26 | rows => 3, |
27 | page => 1 } ); |
28 | |
29 | cmp_ok( $pager->entries_on_this_page, '==', 3, "entries_on_this_page ok" ); |
30 | |
31 | cmp_ok( $pager->next_page, '==', 2, "next_page ok" ); |
32 | |
33 | is( $it->next->title, "Caterwaulin' Blues", "iterator->next ok" ); |
34 | |
35 | $it->next; |
36 | $it->next; |
37 | |
38 | is( $it->next, undef, "next past end of page ok" ); |
39 | |
40 | ( $pager, $it ) = DBICTest::CD->page( |
41 | {}, |
42 | { rows => 2, |
43 | page => 2, |
44 | disable_sql_paging => 1 } ); |
45 | |
46 | cmp_ok( $pager->total_entries, '==', 5, "disable_sql_paging total_entries ok" ); |
47 | |
48 | cmp_ok( $pager->previous_page, '==', 1, "disable_sql_paging previous_page ok" ); |
49 | |
50 | is( $it->next->title, "Caterwaulin' Blues", "disable_sql_paging iterator->next ok" ); |
51 | |
52 | $it->next; |
53 | |
54 | is( $it->next, undef, "disable_sql_paging next past end of page ok" ); |
55 | |
56 | # based on a failing criteria submitted by waswas |
57 | ( $pager, $it ) = DBICTest::CD->page( |
58 | { title => [ |
59 | -and => |
60 | { |
61 | -like => '%bees' |
62 | }, |
63 | { |
64 | -not_like => 'Forkful%' |
65 | } |
66 | ] |
67 | }, |
68 | { rows => 5 } |
69 | ); |
70 | is( $it->count, 1, "complex abstract count ok" ); |