Introduce GOVERNANCE document and empty RESOLUTIONS file.
[dbsrgits/DBIx-Class.git] / t / cdbi / sweet / 08pager.t
CommitLineData
c0329273 1BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
83eef562 2use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat';
3
4f99ad18 4use strict;
5use warnings;
6
7use Test::More;
8
c0329273 9
83eef562 10use DBICTest;
4f99ad18 11
5e7ac8f9 12DBICTest::Schema::CD->load_components(qw/CDBICompat CDBICompat::Pager/);
13
9b0d64fc 14my $schema = DBICTest->init_schema(compose_connection => 1);
c216324a 15
9b0d64fc 16DBICTest::CD->result_source_instance->schema->storage($schema->storage);
4f99ad18 17
18my ( $pager, $it ) = DBICTest::CD->page(
19 {},
20 { order_by => 'title',
21 rows => 3,
22 page => 1 } );
8273e845 23
4f99ad18 24cmp_ok( $pager->entries_on_this_page, '==', 3, "entries_on_this_page ok" );
25
26cmp_ok( $pager->next_page, '==', 2, "next_page ok" );
27
28is( $it->next->title, "Caterwaulin' Blues", "iterator->next ok" );
29
30$it->next;
31$it->next;
32
33is( $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
41cmp_ok( $pager->total_entries, '==', 5, "disable_sql_paging total_entries ok" );
42
43cmp_ok( $pager->previous_page, '==', 1, "disable_sql_paging previous_page ok" );
44
45is( $it->next->title, "Caterwaulin' Blues", "disable_sql_paging iterator->next ok" );
46
47$it->next;
48
49is( $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);
65is( $it->count, 1, "complex abstract count ok" );
65d35121 66
d9bd5195 67done_testing;