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