X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fprefetch%2Fdiamond.t;h=dc3e22c20386cc89a0630c31a68287ebaa4affcb;hb=HEAD;hp=fe30ac83e35dc3fe28acf10297e89e6dbf6b021b;hpb=4ca037d250207a4ade90a3190af16a5fdc2625f4;p=dbsrgits%2FDBIx-Class.git diff --git a/t/prefetch/diamond.t b/t/prefetch/diamond.t index fe30ac8..dc3e22c 100644 --- a/t/prefetch/diamond.t +++ b/t/prefetch/diamond.t @@ -1,9 +1,11 @@ +BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) } + # Test if prefetch and join in diamond relationship fetching the correct rows use strict; use warnings; use Test::More; -use lib qw(t/lib); + use DBICTest; my $schema = DBICTest->init_schema(); @@ -31,18 +33,28 @@ my $ars = $schema->resultset ('Artwork'); # The current artwork belongs to a cd by artist1 # but the artwork itself is painted by artist2 # -# What we try is all possible permutations of join/prefetch +# What we try is all possible permutations of join/prefetch # combinations in both directions, while always expecting to # arrive at the specific artist at the end of each path. my $cd_paths = { 'no cd' => [], + 'no cd empty' => [ '' ], + 'no cd undef' => [ undef ], + 'no cd href' => [ {} ], + 'no cd aoh' => [ [{}] ], + 'no cd complex' => [ [ [ undef ] ] ], 'cd' => ['cd'], 'cd->artist1' => [{'cd' => 'artist'}] }; my $a2a_paths = { 'no a2a' => [], + 'no a2a empty ' => [ '' ], + 'no a2a undef' => [ undef ], + 'no a2a href' => [ {} ], + 'no a2a aoh' => [ [{}] ], + 'no a2a complex' => [ [ '' ] ], 'a2a' => ['artwork_to_artist'], 'a2a->artist2' => [{'artwork_to_artist' => 'artist'}] }; @@ -96,12 +108,12 @@ foreach my $cd_path (keys %$cd_paths) { } } -plan tests => (scalar (keys %tests) * 3); - foreach my $name (keys %tests) { foreach my $artwork ($tests{$name}->all()) { is($artwork->id, 1, $name . ', correct artwork'); is($artwork->cd->artist->artistid, 1, $name . ', correct artist_id over cd'); is($artwork->artwork_to_artist->first->artist->artistid, 2, $name . ', correct artist_id over A2A'); } -} \ No newline at end of file +} + +done_testing;