be336e42c8dfa29493a282c074fb3d58eed8f076
[dbsrgits/DBIx-Class.git] / t / prefetch / attrs_untouched.t
1 use warnings;
2
3 use Test::More;
4 use lib qw(t/lib);
5 use DBICTest;
6
7 use Data::Dumper;
8 $Data::Dumper::Sortkeys = 1;
9
10 my $schema = DBICTest->init_schema();
11
12 plan tests => 3;
13
14 # bug in 0.07000 caused attr (join/prefetch) to be modifed by search
15 # so we check the search & attr arrays are not modified
16 my $search = { 'artist.name' => 'Caterwauler McCrae' };
17 my $attr = { prefetch => [ qw/artist liner_notes/ ],
18              order_by => 'me.cdid' };
19 my $search_str = Dumper($search);
20 my $attr_str = Dumper($attr);
21
22 my $rs = $schema->resultset("CD")->search($search, $attr);
23
24 is(Dumper($search), $search_str, 'Search hash untouched after search()');
25 is(Dumper($attr), $attr_str, 'Attribute hash untouched after search()');
26 cmp_ok($rs + 0, '==', 3, 'Correct number of records returned');