added failing test case
[dbsrgits/DBIx-Class.git] / t / 90join_torture.t
CommitLineData
ae515736 1use strict;
2use warnings;
3
4use Test::More;
5use lib qw(t/lib);
6use DBICTest;
7
8my $schema = DBICTest->init_schema();
9
b253a82b 10plan tests => 5;
ae515736 11
12my $rs1 = $schema->resultset("Artist")->search({ 'tags.tag' => 'Blue' }, { join => {'cds' => 'tracks'}, prefetch => {'cds' => 'tags'} });
13my @artists = $rs1->all;
14cmp_ok(@artists, '==', 1, "Two artists returned");
15
16my $rs2 = $rs1->search({ artistid => '1' }, { join => {'cds' => {'cd_to_producer' => 'producer'} } });
b253a82b 17
18my @artists2 = $rs2->search({ 'producer.name' => 'Matt S Trout' });
19my @cds = $artists2[0]->cds;
20cmp_ok(scalar @cds, '==', 1, "condition based on inherited join okay");
21
22my $rs3 = $rs2->search_related('cds')->search({'title' => 'Forkful of bees'});
23cpm_ok($rs3->count, '==', 3, "Three artists returned");
24exit;
ae515736 25
26my $rs4 = $schema->resultset("CD")->search({ 'artist.artistid' => '1' }, { join => ['tracks', 'artist'], prefetch => 'artist' });
27my @rs4_results = $rs4->all;
28
29
30is($rs4_results[0]->cdid, 1, "correct artist returned");
31
32my $rs5 = $rs4->search({'tracks.title' => 'Sticky Honey'});
33is($rs5->count, 1, "search without using previous joins okay");
34
351;