6 use lib 't/cdbi/testlib';
7 use DBIC::Test::SQLite;
9 DBICTest::Schema::CD->load_components(qw/CDBICompat CDBICompat::Pager/);
11 my $schema = DBICTest->init_schema(compose_connection => 1);
13 DBICTest::CD->result_source_instance->schema->storage($schema->storage);
15 my ( $pager, $it ) = DBICTest::CD->page(
17 { order_by => 'title',
21 cmp_ok( $pager->entries_on_this_page, '==', 3, "entries_on_this_page ok" );
23 cmp_ok( $pager->next_page, '==', 2, "next_page ok" );
25 is( $it->next->title, "Caterwaulin' Blues", "iterator->next ok" );
30 is( $it->next, undef, "next past end of page ok" );
32 ( $pager, $it ) = DBICTest::CD->page(
36 disable_sql_paging => 1 } );
38 cmp_ok( $pager->total_entries, '==', 5, "disable_sql_paging total_entries ok" );
40 cmp_ok( $pager->previous_page, '==', 1, "disable_sql_paging previous_page ok" );
42 is( $it->next->title, "Caterwaulin' Blues", "disable_sql_paging iterator->next ok" );
46 is( $it->next, undef, "disable_sql_paging next past end of page ok" );
48 # based on a failing criteria submitted by waswas
49 ( $pager, $it ) = DBICTest::CD->page(
56 -not_like => 'Forkful%'
62 is( $it->count, 1, "complex abstract count ok" );
64 # cleanup globals so we do not trigger the leaktest
65 for ( map { DBICTest->schema->class($_) } DBICTest->schema->sources ) {
66 $_->class_resolver(undef);
67 $_->resultset_instance(undef);
68 $_->result_source_instance(undef);
71 no warnings qw/redefine once/;
72 *DBICTest::schema = sub {};