add_relationship, relationship_info, relationships moved to ResultSource
[dbsrgits/DBIx-Class.git] / t / cdbi-sweet-t / 08pager.t
CommitLineData
4f99ad18 1use strict;
2use warnings;
3
4use Test::More;
5
6eval "use DBD::SQLite";
7plan skip_all => 'needs DBD::SQLite for testing' if $@;
8
9plan tests => 10;
10
11use lib 't/lib';
12
8452e496 13use_ok('DBICTest::HelperRels');
4f99ad18 14
15DBICTest::CD->load_components(qw/CDBICompat::Pager/);
16
17my ( $pager, $it ) = DBICTest::CD->page(
18 {},
19 { order_by => 'title',
20 rows => 3,
21 page => 1 } );
22
23cmp_ok( $pager->entries_on_this_page, '==', 3, "entries_on_this_page ok" );
24
25cmp_ok( $pager->next_page, '==', 2, "next_page ok" );
26
27is( $it->next->title, "Caterwaulin' Blues", "iterator->next ok" );
28
29$it->next;
30$it->next;
31
32is( $it->next, undef, "next past end of page ok" );
33
34( $pager, $it ) = DBICTest::CD->page(
35 {},
36 { rows => 2,
37 page => 2,
38 disable_sql_paging => 1 } );
39
40cmp_ok( $pager->total_entries, '==', 5, "disable_sql_paging total_entries ok" );
41
42cmp_ok( $pager->previous_page, '==', 1, "disable_sql_paging previous_page ok" );
43
44is( $it->next->title, "Caterwaulin' Blues", "disable_sql_paging iterator->next ok" );
45
46$it->next;
47
48is( $it->next, undef, "disable_sql_paging next past end of page ok" );
49
50# based on a failing criteria submitted by waswas
51( $pager, $it ) = DBICTest::CD->page(
52 { title => [
53 -and =>
54 {
55 -like => '%bees'
56 },
57 {
58 -not_like => 'Forkful%'
59 }
60 ]
61 },
62 { rows => 5 }
63);
64is( $it->count, 1, "complex abstract count ok" );