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