Introduce GOVERNANCE document and empty RESOLUTIONS file.
[dbsrgits/DBIx-Class.git] / t / prefetch / one_to_many_to_one.t
CommitLineData
c0329273 1BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
2
13d06949 3use strict;
4use warnings;
5
6use Test::More;
13d06949 7
c0329273 8
13d06949 9use DBICTest;
10
11my $schema = DBICTest->init_schema();
12
13my $artist = $schema->resultset ('Artist')->find ({artistid => 1});
14is ($artist->cds->count, 3, 'Correct number of CDs');
15is ($artist->cds->search_related ('genre')->count, 1, 'Only one of the cds has a genre');
16
49eeb48d 17$schema->is_executed_querycount( sub {
18 my $pref = $schema->resultset ('Artist')
13d06949 19 ->search ({ 'me.artistid' => $artist->id }, { prefetch => { cds => 'genre' } })
20 ->next;
21
49eeb48d 22 is ($pref->cds->count, 3, 'Correct number of CDs prefetched');
23 is ($pref->cds->search_related ('genre')->count, 1, 'Only one of the prefetched cds has a prefetched genre');
13d06949 24
49eeb48d 25}, 1, 'All happened within one query only');
13d06949 26
13d06949 27done_testing;