Extend test
[dbsrgits/DBIx-Class.git] / t / prefetch / attrs_untouched.t
CommitLineData
e9bd1473 1use warnings;
2
3use Test::More;
4use Test::Exception;
5use lib qw(t/lib);
6use DBICTest;
7use Data::Dumper;
8
9my $schema = DBICTest->init_schema();
10
11my $orig_debug = $schema->storage->debug;
12
13use IO::File;
14
15BEGIN {
16 eval "use DBD::SQLite";
17 plan $@
18 ? ( skip_all => 'needs DBD::SQLite for testing' )
19 : ( tests => 3 );
20}
21
e9bd1473 22# bug in 0.07000 caused attr (join/prefetch) to be modifed by search
23# so we check the search & attr arrays are not modified
24my $search = { 'artist.name' => 'Caterwauler McCrae' };
25my $attr = { prefetch => [ qw/artist liner_notes/ ],
26 order_by => 'me.cdid' };
27my $search_str = Dumper($search);
28my $attr_str = Dumper($attr);
29
30my $rs = $schema->resultset("CD")->search($search, $attr);
31
32is(Dumper($search), $search_str, 'Search hash untouched after search()');
33is(Dumper($attr), $attr_str, 'Attribute hash untouched after search()');
34cmp_ok($rs + 0, '==', 3, 'Correct number of records returned');