2 use Test::More tests => 6;
7 use DBIx::Class::Schema::Loader;
9 # test skip_relationships
10 my $regular = schema_with();
11 is( ref($regular->source('Bar')->relationship_info('fooref')), 'HASH',
12 'regularly-made schema has fooref rel',
14 my $skip_rel = schema_with( skip_relationships => 1 );
15 is_deeply( $skip_rel->source('Bar')->relationship_info('fooref'), undef,
16 'skip_relationships blocks generation of fooref rel',
20 # test relationship_attrs
22 schema_with( relationship_attrs => 'laughably invalid!!!' );
23 } qr/relationship_attrs/, 'throws error for invalid relationship_attrs';
27 my $nodelete = schema_with( relationship_attrs =>
29 all => { cascade_delete => 0 },
30 belongs_to => { cascade_delete => 1 },
34 my $bars_info = $nodelete->source('Foo')->relationship_info('bars');
36 #die Dumper([ $nodelete->source('Foo')->relationships() ]);
37 my $fooref_info = $nodelete->source('Bar')->relationship_info('fooref');
38 is( ref($fooref_info), 'HASH',
39 'fooref rel is present',
41 is( $bars_info->{attrs}->{cascade_delete}, 0,
42 'relationship_attrs settings seem to be getting through to the generated rels',
44 is( $fooref_info->{attrs}->{cascade_delete}, 1,
45 'belongs_to in relationship_attrs overrides all def',
50 #### generates a new schema with the given opts every time it's called
51 my $schema_counter = 0;
54 DBIx::Class::Schema::Loader::make_schema_at(
55 'DBICTest::Schema::'.$schema_counter,
56 { naming => 'current', @_ },
57 [ $make_dbictest_db::dsn ],
59 "DBICTest::Schema::$schema_counter"->clone;