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