Commit | Line | Data |
c0329273 |
1 | BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) } |
2 | |
9ae300a4 |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use Test::More; |
c0329273 |
7 | |
9ae300a4 |
8 | use DBICTest; |
9 | |
10 | my $schema = DBICTest->init_schema(); |
11 | |
12 | my $art = $schema->resultset('Artist')->find( |
13 | { 'me.artistid' => 1 }, |
14 | { prefetch => 'cds', order_by => { -desc => 'cds.year' } } |
15 | ); |
16 | |
17 | is ( |
18 | $art->cds->search({ year => 1999 })->next->year, |
19 | 1999, |
20 | 'Found expected CD with year 1999 after refined search', |
21 | ); |
22 | |
23 | is ( |
24 | $art->cds->count({ year => 1999 }), |
25 | 1, |
26 | 'Correct refined count', |
27 | ); |
28 | |
29 | # this still should emit no queries: |
49eeb48d |
30 | $schema->is_executed_querycount( sub { |
9ae300a4 |
31 | |
32 | my $cds = $art->cds; |
33 | is ( |
34 | $cds->count, |
35 | 3, |
36 | 'Correct prefetched count', |
37 | ); |
38 | |
39 | my @years = qw(2001 1999 1997); |
40 | while (my $cd = $cds->next) { |
41 | is ( |
42 | $cd->year, |
43 | (shift @years), |
44 | 'Correct prefetched cd year', |
45 | ); |
46 | } |
47 | |
49eeb48d |
48 | }, 0, 'No queries on prefetched operations'); |
9ae300a4 |
49 | |
50 | done_testing; |