+++ /dev/null
----
-abstract: ~
-author:
- - Luke Saunders <luke@shadowcatsystems.co.uk>
-build_requires:
- Test::More: 0.7
-distribution_type: module
-generated_by: Module::Install version 0.68
-license: perl
-meta-spec:
- url: http://module-build.sourceforge.net/META-spec-v1.3.html
- version: 1.3
-name: DBIx-Class-Fixtures
-no_index:
- directory:
- - inc
- - t
-provides:
- DBIx::Class::Fixtures:
- file: lib/DBIx/Class/Fixtures.pm
- version: 1.000001
- DBIx::Class::Fixtures::Schema:
- file: lib/DBIx/Class/Fixtures/Schema.pm
- DBIx::Class::Fixtures::SchemaVersioned:
- file: lib/DBIx/Class/Fixtures/SchemaVersioned.pm
- version: 0
- DBIx::Class::Fixtures::Versioned:
- file: lib/DBIx/Class/Fixtures/Versioned.pm
-requires:
- Class::Accessor::Grouped: 0.06
- Config::Any: 0.08
- DBIx::Class: 0.08
- DBIx::Class::Schema::Loader: 0.04004
- Data::Dump::Streamer: 2.05
- Data::Visitor: 0.15
- DateTime: 0.41
- DateTime::Format::MySQL: 0.04
- File::Copy::Recursive: 0.35
- File::Slurp: 999.13
- Hash::Merge: 0.1
- JSON::Syck: 0.26
- Path::Class: 0.16
- perl: 5.6.1
-tests: t/*.t
-version: 1.000001
Specifies whether to automatically dump might_have relationships. Should be a hash with one attribute - fetch. Set fetch to 1 or 0.
{
- might_have: [{
+ might_have: {
fetch: 1
},
sets: [{
# fetch objects
my $rs = $schema->resultset($source->{class});
+
+ if ($source->{cond} and ref $source->{cond} eq 'HASH') {
+ # if value starts with / assume it's meant to be passed as a scalar ref to dbic
+ # ideally this would substitute deeply
+ $source->{cond} = { map { $_ => ($source->{cond}->{$_} =~ s/^\\//) ? \$source->{cond}->{$_} : $source->{cond}->{$_} } keys %{$source->{cond}} };
+ }
+
$rs = $rs->search($source->{cond}, { join => $source->{join} }) if ($source->{cond});
$self->msg("- dumping $source->{class}");
my @objects;
--- /dev/null
+#!perl
+
+use DBIx::Class::Fixtures;
+use Test::More tests => 7;
+use lib qw(t/lib);
+use DBICTest;
+use Path::Class;
+use Data::Dumper;
+
+# set up and populate schema
+ok(my $schema = DBICTest->init_schema(), 'got schema');
+
+my $config_dir = 't/var/configs';
+
+# do dump
+ok(my $fixtures = DBIx::Class::Fixtures->new({ config_dir => $config_dir, debug => 0 }), 'object created with correct config dir');
+
+ok($fixtures->dump({ config => 'scalar_ref.json', schema => $schema, directory => 't/var/fixtures' }), 'simple dump executed okay');
+
+{
+ # check dump is okay
+ my $dir = dir('t/var/fixtures/artist');
+ my @children = $dir->children;
+ is(scalar(@children), 1, 'right number of fixtures created');
+
+ my $fix_file = $children[0];
+ my $HASH1; eval($fix_file->slurp());
+
+ is($HASH1->{name}, 'We Are Goth', 'correct artist dumped');
+}
+
+{
+ # check dump is okay
+ my $dir = dir('t/var/fixtures/cd');
+ my @children = $dir->children;
+ is(scalar(@children), 1, 'right number of fixtures created');
+
+ my $fix_file = $children[0];
+ my $HASH1; eval($fix_file->slurp());
+
+ is($HASH1->{title}, 'Come Be Depressed With Us', 'correct cd dumped');
+}
+
+
--- /dev/null
+{
+ might_have: {
+ fetch: 0
+ },
+ has_many: {
+ fetch: 0
+ },
+ sets: [{
+ class: 'Artist',
+ cond: { me.name: '\= "We Are Goth"' },
+ quantity: all,
+ fetch: [{
+ rel: 'cds',
+ cond: { 'me.title': '\LIKE "%with us"' }
+ }]
+ }]
+}
\ No newline at end of file
+++ /dev/null
-1.000001
\ No newline at end of file
+++ /dev/null
-$HASH1 = {
- artistid => 1,
- name => 'Caterwauler McCrae'
- };