Actually updated the changes file! lookitme, andyg!
[dbsrgits/DBIx-Class.git] / t / 15limit.t
CommitLineData
aeaf3ce2 1use strict;
2use Test::More;
3
4BEGIN {
5 eval "use DBD::SQLite";
9229f20a 6 plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 10);
aeaf3ce2 7}
8
9use lib qw(t/lib);
10
11use_ok('DBICTest');
12
13# test LIMIT
14my $it = DBICTest::CD->search( {},
15 { rows => 3,
16 order_by => 'title' }
17);
18is( $it->count, 3, "count ok" );
19is( $it->next->title, "Caterwaulin' Blues", "iterator->next ok" );
20$it->next;
21$it->next;
22is( $it->next, undef, "next past end of resultset ok" );
23
24# test OFFSET
25my @cds = DBICTest::CD->search( {},
26 { rows => 2,
27 offset => 2,
28 order_by => 'year' }
29);
30is( $cds[0]->title, "Spoonful of bees", "offset ok" );
3c5b25c5 31
9229f20a 32# test software-based limiting
33$it = DBICTest::CD->search( {},
34 { rows => 3,
35 software_limit => 1,
36 order_by => 'title' }
37);
38is( $it->count, 3, "software limit count ok" );
39is( $it->next->title, "Caterwaulin' Blues", "software iterator->next ok" );
40$it->next;
41$it->next;
42is( $it->next, undef, "software next past end of resultset ok" );
43
44@cds = DBICTest::CD->search( {},
45 { rows => 2,
46 offset => 2,
47 software_limit => 1,
48 order_by => 'year' }
49);
50is( $cds[0]->title, "Spoonful of bees", "software offset ok" );
51
3c5b25c5 52# based on a failing criteria submitted by waswas
53# requires SQL::Abstract >= 1.20
54$it = DBICTest::CD->search(
55 { title => [
56 -and =>
57 {
58 -like => '%bees'
59 },
60 {
61 -not_like => 'Forkful%'
62 }
63 ]
64 },
65 { rows => 5 }
66);
67is( $it->count, 1, "complex abstract count ok" );