Remove redundant skip checks in CDBICompat tests
[dbsrgits/DBIx-Class.git] / t / cdbi / abstract / search_where.t
CommitLineData
e60dc79f 1use Test::More;
2
3use strict;
4use warnings;
5
a40329c4 6use lib 't/cdbi/testlib';
7use Film;
e60dc79f 8
9Film->create({ Title => $_, Rating => "PG" }) for ("Superman", "Super Fuzz");
10Film->create({ Title => "Batman", Rating => "PG13" });
11
12my $superman = Film->search_where( Title => "Superman" );
13is $superman->next->Title, "Superman", "search_where() as iterator";
14is $superman->next, undef;
15
d37c21dc 16{
17 my @supers = Film->search_where({ title => { 'like' => 'Super%' } });
18 is_deeply [sort map $_->Title, @supers],
19 [sort ("Super Fuzz", "Superman")], 'like';
20}
8273e845 21
d37c21dc 22
e60dc79f 23my @all = Film->search_where({}, { order_by => "Title ASC" });
24is_deeply ["Batman", "Super Fuzz", "Superman"],
25 [map $_->Title, @all],
26 "order_by ASC";
27
28@all = Film->search_where({}, { order_by => "Title DESC" });
29is_deeply ["Superman", "Super Fuzz", "Batman"],
30 [map $_->Title, @all],
31 "order_by DESC";
32
33@all = Film->search_where({ Rating => "PG" }, { limit => 1, order_by => "Title ASC" });
34is_deeply ["Super Fuzz"],
35 [map $_->Title, @all],
36 "where, limit";
37
38@all = Film->search_where({}, { limit => 2, order_by => "Title ASC" });
39is_deeply ["Batman", "Super Fuzz"],
40 [map $_->Title, @all],
41 "limit";
42
43@all = Film->search_where({}, { offset => 1, order_by => "Title ASC" });
44is_deeply ["Super Fuzz", "Superman"],
45 [map $_->Title, @all],
46 "offset";
47
48@all = Film->search_where({}, { limit => 1, offset => 1, order_by => "Title ASC" });
49is_deeply ["Super Fuzz"],
50 [map $_->Title, @all],
51 "limit + offset";
52
53@all = Film->search_where({}, { limit => 2, offset => 1,
54 limit_dialect => "Top", order_by => "Title ASC"
55 });
56is_deeply ["Super Fuzz", "Superman"],
57 [map $_->Title, @all],
58 "limit_dialect ignored";
59
d9bd5195 60done_testing;