Commit | Line | Data |
0567538f |
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 |
3712e4f4 |
9 | my $it = DBICTest->class("CD")->search( {}, |
0567538f |
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 |
3712e4f4 |
20 | my @cds = DBICTest->class("CD")->search( {}, |
0567538f |
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 |
3712e4f4 |
28 | $it = DBICTest->class("CD")->search( {}, |
0567538f |
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 | |
3712e4f4 |
39 | @cds = DBICTest->class("CD")->search( {}, |
0567538f |
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 |
3712e4f4 |
49 | $it = DBICTest->class("CD")->search( |
0567538f |
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; |