Switch most remaining debug-hooks to $dbictest_schema->is_executed_querycount()
[dbsrgits/DBIx-Class.git] / t / prefetch / false_colvalues.t
1 use warnings;
2 use strict;
3
4 use Test::More;
5 use Test::Deep;
6
7 use lib qw(t/lib);
8 use DBICTest;
9
10 my $schema = DBICTest->init_schema( no_populate => 1 );
11
12 $schema->resultset('CD')->create({
13   cdid => 0, title => '', year => 0, genreid => 0, single_track => 0, artist => {
14     artistid => 0, name => '', rank => 0, charfield => 0,
15   },
16 });
17
18 $schema->is_executed_querycount( sub {
19   my $cd = $schema->resultset('CD')->search( {}, { prefetch => 'artist' })->next;
20
21   cmp_deeply
22     { $cd->get_columns },
23     { artist => 0, cdid => 0, genreid => 0, single_track => 0, title => '', year => 0 },
24     'Expected CD columns present',
25   ;
26
27   cmp_deeply
28     { $cd->artist->get_columns },
29     { artistid => 0, charfield => 0, name => "", rank => 0 },
30     'Expected Artist columns present',
31   ;
32 }, 1, 'Only one query fired - prefetch worked' );
33
34 done_testing;