Use source->name or source->source_name for naming of sources in a central method
[dbsrgits/DBIx-Class-Fixtures.git] / t / 16-rules-hasmany.t
CommitLineData
06b7a1cc 1#!perl
2
3use DBIx::Class::Fixtures;
4use Test::More tests => 11;
5use lib qw(t/lib);
6use DBICTest;
7use Path::Class;
8use Data::Dumper;
9
10# set up and populate schema
11ok(my $schema = DBICTest->init_schema(), 'got schema');
12
13my $config_dir = 't/var/configs';
14
15# do dump
16ok(my $fixtures = DBIx::Class::Fixtures->new({ config_dir => $config_dir, debug => 0 }), 'object created with correct config dir');
17ok($fixtures->dump({ config => 'rules2.json', schema => $schema, directory => 't/var/fixtures' }), 'quantity dump executed okay');
18
19# check dump is okay
20foreach my $test (
21 [ 'artist', 1, 'Artist', 'artistid' ],
dcdf675f 22 [ 'CD', 2, 'CD', 'cdid' ],
06b7a1cc 23) {
24 my ($dirname, $count, $moniker, $id) = @$test;
25 my $dir = dir("t/var/fixtures/$dirname");
26 my @children = $dir->children;
27 is(scalar(@children), $count, "right number of $dirname fixtures created");
28
29 foreach my $fix_file (@children) {
30 my $HASH1; eval($fix_file->slurp());
31 is(ref $HASH1, 'HASH', 'fixture evals into hash');
32 my $obj = $schema->resultset($moniker)->find($HASH1->{$id});
33 is_deeply({$obj->get_columns}, $HASH1, "dumped fixture is equivalent to $dirname row");
34 }
35}
36