Fix test suite to work again with DBICTEST_SQLITE_USE_FILE
[dbsrgits/DBIx-Class.git] / t / cdbi / sweet / 08pager.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5
6 use lib 't/cdbi/testlib';
7 use DBIC::Test::SQLite;
8
9 DBICTest::Schema::CD->load_components(qw/CDBICompat CDBICompat::Pager/);
10
11 my $schema = DBICTest->init_schema(compose_connection => 1);
12
13 DBICTest::CD->result_source_instance->schema->storage($schema->storage);
14
15 my ( $pager, $it ) = DBICTest::CD->page(
16     {},
17     { order_by => 'title',
18       rows => 3,
19       page => 1 } );
20
21 cmp_ok( $pager->entries_on_this_page, '==', 3, "entries_on_this_page ok" );
22
23 cmp_ok( $pager->next_page, '==', 2, "next_page ok" );
24
25 is( $it->next->title, "Caterwaulin' Blues", "iterator->next ok" );
26
27 $it->next;
28 $it->next;
29
30 is( $it->next, undef, "next past end of page ok" );
31
32 ( $pager, $it ) = DBICTest::CD->page(
33     {},
34     { rows => 2,
35       page => 2,
36       disable_sql_paging => 1 } );
37
38 cmp_ok( $pager->total_entries, '==', 5, "disable_sql_paging total_entries ok" );
39
40 cmp_ok( $pager->previous_page, '==', 1, "disable_sql_paging previous_page ok" );
41
42 is( $it->next->title, "Caterwaulin' Blues", "disable_sql_paging iterator->next ok" );
43
44 $it->next;
45
46 is( $it->next, undef, "disable_sql_paging next past end of page ok" );
47
48 # based on a failing criteria submitted by waswas
49 ( $pager, $it ) = DBICTest::CD->page(
50     { title => [
51         -and =>
52             {
53                 -like => '%bees'
54             },
55             {
56                 -not_like => 'Forkful%'
57             }
58         ]
59     },
60     { rows => 5 }
61 );
62 is( $it->count, 1, "complex abstract count ok" );
63
64 done_testing;