Removed BasicRels and reorganized where the various init/setup code resides.
[dbsrgits/DBIx-Class.git] / t / run / 17join_count.tl
1 sub run_tests {
2 my $schema = shift;
3
4 eval "use DBD::SQLite";
5 plan skip_all => 'needs DBD::SQLite for testing' if $@;
6 plan tests => 4;
7
8 cmp_ok($schema->resultset("CD")->count({ 'artist.name' => 'Caterwauler McCrae' },
9                            { join => 'artist' }),
10            '==', 3, 'Count by has_a ok');
11
12 cmp_ok($schema->resultset("CD")->count({ 'tags.tag' => 'Blue' }, { join => 'tags' }),
13            '==', 4, 'Count by has_many ok');
14
15 cmp_ok($schema->resultset("CD")->count(
16            { 'liner_notes.notes' => { '!=' =>  undef } },
17            { join => 'liner_notes' }),
18            '==', 3, 'Count by might_have ok');
19
20 cmp_ok($schema->resultset("CD")->count(
21            { 'year' => { '>', 1998 }, 'tags.tag' => 'Cheesy',
22                'liner_notes.notes' => { 'like' => 'Buy%' } },
23            { join => [ qw/tags liner_notes/ ] } ),
24            '==', 2, "Mixed count ok");
25
26 }
27
28 1;