Massive cleanup of DateTime test dependencies, other interim
[dbsrgits/DBIx-Class.git] / t / 77join_count.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5 use lib qw(t/lib);
6 use DBICTest;
7
8 my $schema = DBICTest->init_schema();
9
10 cmp_ok($schema->resultset("CD")->count({ 'artist.name' => 'Caterwauler McCrae' },
11                            { join => 'artist' }),
12            '==', 3, 'Count by has_a ok');
13
14 cmp_ok($schema->resultset("CD")->count({ 'tags.tag' => 'Blue' }, { join => 'tags' }),
15            '==', 4, 'Count by has_many ok');
16
17 cmp_ok($schema->resultset("CD")->count(
18            { 'liner_notes.notes' => { '!=' =>  undef } },
19            { join => 'liner_notes' }),
20            '==', 3, 'Count by might_have ok');
21
22 cmp_ok($schema->resultset("CD")->count(
23            { 'year' => { '>', 1998 }, 'tags.tag' => 'Cheesy',
24                'liner_notes.notes' => { 'like' => 'Buy%' } },
25            { join => [ qw/tags liner_notes/ ] } ),
26            '==', 2, "Mixed count ok");
27
28 done_testing;