Commit | Line | Data |
c0329273 |
1 | BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) } |
2 | |
13d06949 |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use Test::More; |
13d06949 |
7 | |
c0329273 |
8 | |
13d06949 |
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 | |
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 |
27 | done_testing; |