space-compress tests making them readable - no changes
[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 my $orig_debug = $schema->storage->debug;
19
20 my $queries = 0;
21 $schema->storage->debugcb(sub { $queries++; });
22 $schema->storage->debug(1);
23
24 my $cd = $schema->resultset('CD')->search( {}, { prefetch => 'artist' })->next;
25
26 cmp_deeply
27   { $cd->get_columns },
28   { artist => 0, cdid => 0, genreid => 0, single_track => 0, title => '', year => 0 },
29   'Expected CD columns present',
30 ;
31
32 cmp_deeply
33   { $cd->artist->get_columns },
34   { artistid => 0, charfield => 0, name => "", rank => 0 },
35   'Expected Artist columns present',
36 ;
37
38 is $queries, 1, 'Only one query fired - prefetch worked';
39
40 $schema->storage->debugcb(undef);
41 $schema->storage->debug($orig_debug);
42
43 done_testing;