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 | } |
68de9438 |
12 | plan tests => 10; |
289ba852 |
13 | } |
4f99ad18 |
14 | |
15 | use lib 't/lib'; |
16 | |
58d387fe |
17 | use_ok('DBICTest'); |
4f99ad18 |
18 | |
5e7ac8f9 |
19 | DBICTest::Schema::CD->load_components(qw/CDBICompat CDBICompat::Pager/); |
20 | |
9b0d64fc |
21 | my $schema = DBICTest->init_schema(compose_connection => 1); |
c216324a |
22 | |
9b0d64fc |
23 | DBICTest::CD->result_source_instance->schema->storage($schema->storage); |
4f99ad18 |
24 | |
25 | my ( $pager, $it ) = DBICTest::CD->page( |
26 | {}, |
27 | { order_by => 'title', |
28 | rows => 3, |
29 | page => 1 } ); |
30 | |
31 | cmp_ok( $pager->entries_on_this_page, '==', 3, "entries_on_this_page ok" ); |
32 | |
33 | cmp_ok( $pager->next_page, '==', 2, "next_page ok" ); |
34 | |
35 | is( $it->next->title, "Caterwaulin' Blues", "iterator->next ok" ); |
36 | |
37 | $it->next; |
38 | $it->next; |
39 | |
40 | is( $it->next, undef, "next past end of page ok" ); |
41 | |
42 | ( $pager, $it ) = DBICTest::CD->page( |
43 | {}, |
44 | { rows => 2, |
45 | page => 2, |
46 | disable_sql_paging => 1 } ); |
47 | |
48 | cmp_ok( $pager->total_entries, '==', 5, "disable_sql_paging total_entries ok" ); |
49 | |
50 | cmp_ok( $pager->previous_page, '==', 1, "disable_sql_paging previous_page ok" ); |
51 | |
52 | is( $it->next->title, "Caterwaulin' Blues", "disable_sql_paging iterator->next ok" ); |
53 | |
54 | $it->next; |
55 | |
56 | is( $it->next, undef, "disable_sql_paging next past end of page ok" ); |
57 | |
58 | # based on a failing criteria submitted by waswas |
59 | ( $pager, $it ) = DBICTest::CD->page( |
60 | { title => [ |
61 | -and => |
62 | { |
63 | -like => '%bees' |
64 | }, |
65 | { |
66 | -not_like => 'Forkful%' |
67 | } |
68 | ] |
69 | }, |
70 | { rows => 5 } |
71 | ); |
72 | is( $it->count, 1, "complex abstract count ok" ); |