Bring out the big-paranoia-harness - make describe_env infallible
[dbsrgits/DBIx-Class.git] / t / 77join_count.t
1 BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
2
3 use strict;
4 use warnings;
5
6 use Test::More;
7
8 use DBICTest;
9
10 my $schema = DBICTest->init_schema();
11
12 cmp_ok($schema->resultset("CD")->count({ 'artist.name' => 'Caterwauler McCrae' },
13                            { join => 'artist' }),
14            '==', 3, 'Count by has_a ok');
15
16 cmp_ok($schema->resultset("CD")->count({ 'tags.tag' => 'Blue' }, { join => 'tags' }),
17            '==', 4, 'Count by has_many ok');
18
19 cmp_ok($schema->resultset("CD")->count(
20            { 'liner_notes.notes' => { '!=' =>  undef } },
21            { join => 'liner_notes' }),
22            '==', 3, 'Count by might_have ok');
23
24 cmp_ok($schema->resultset("CD")->count(
25            { 'year' => { '>', 1998 }, 'tags.tag' => 'Cheesy',
26                'liner_notes.notes' => { 'like' => 'Buy%' } },
27            { join => [ qw/tags liner_notes/ ] } ),
28            '==', 2, "Mixed count ok");
29
30 done_testing;