Commit | Line | Data |
c0329273 |
1 | BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) } |
83eef562 |
2 | use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat'; |
3 | |
4f99ad18 |
4 | use strict; |
5 | use warnings; |
6 | |
7 | use Test::More; |
8 | |
c0329273 |
9 | |
83eef562 |
10 | use DBICTest; |
4f99ad18 |
11 | |
5e7ac8f9 |
12 | DBICTest::Schema::CD->load_components(qw/CDBICompat CDBICompat::Pager/); |
13 | |
9b0d64fc |
14 | my $schema = DBICTest->init_schema(compose_connection => 1); |
c216324a |
15 | |
9b0d64fc |
16 | DBICTest::CD->result_source_instance->schema->storage($schema->storage); |
4f99ad18 |
17 | |
18 | my ( $pager, $it ) = DBICTest::CD->page( |
19 | {}, |
20 | { order_by => 'title', |
21 | rows => 3, |
22 | page => 1 } ); |
8273e845 |
23 | |
4f99ad18 |
24 | cmp_ok( $pager->entries_on_this_page, '==', 3, "entries_on_this_page ok" ); |
25 | |
26 | cmp_ok( $pager->next_page, '==', 2, "next_page ok" ); |
27 | |
28 | is( $it->next->title, "Caterwaulin' Blues", "iterator->next ok" ); |
29 | |
30 | $it->next; |
31 | $it->next; |
32 | |
33 | is( $it->next, undef, "next past end of page ok" ); |
34 | |
35 | ( $pager, $it ) = DBICTest::CD->page( |
36 | {}, |
37 | { rows => 2, |
38 | page => 2, |
39 | disable_sql_paging => 1 } ); |
40 | |
41 | cmp_ok( $pager->total_entries, '==', 5, "disable_sql_paging total_entries ok" ); |
42 | |
43 | cmp_ok( $pager->previous_page, '==', 1, "disable_sql_paging previous_page ok" ); |
44 | |
45 | is( $it->next->title, "Caterwaulin' Blues", "disable_sql_paging iterator->next ok" ); |
46 | |
47 | $it->next; |
48 | |
49 | is( $it->next, undef, "disable_sql_paging next past end of page ok" ); |
50 | |
51 | # based on a failing criteria submitted by waswas |
52 | ( $pager, $it ) = DBICTest::CD->page( |
53 | { title => [ |
8273e845 |
54 | -and => |
4f99ad18 |
55 | { |
56 | -like => '%bees' |
57 | }, |
58 | { |
59 | -not_like => 'Forkful%' |
60 | } |
61 | ] |
62 | }, |
63 | { rows => 5 } |
64 | ); |
65 | is( $it->count, 1, "complex abstract count ok" ); |
65d35121 |
66 | |
d9bd5195 |
67 | done_testing; |