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