1 use DBIx::Class::Schema::Loader::Optional::Dependencies
2 -skip_all_without => 'test_backcompat';
7 use lib qw(t/backcompat/0.04006/lib);
10 local $SIG{__WARN__} = sub {
11 warn @_ unless $_[0] =~ /Dynamic schema|really_erase_my_files/;
14 # Takes a $schema as input, runs 4 basic tests
16 my ($testname, $schema) = @_;
18 $schema = $schema->clone if !ref $schema;
19 isa_ok($schema, 'DBIx::Class::Schema', $testname);
21 my $foo_rs = $schema->resultset('Bar')->search({ barid => 3})->search_related('fooref');
22 isa_ok($foo_rs, 'DBIx::Class::ResultSet', $testname);
24 my $foo_first = $foo_rs->first;
25 like(ref $foo_first, qr/DBICTest::Schema::\d+::Foo/, $testname);
27 my $foo_first_text = $foo_first->footext;
28 is($foo_first_text, 'Foo record associated with the Bar with barid 3');
33 package DBICTest::Schema::5;
34 use base qw/ DBIx::Class::Schema::Loader /;
35 __PACKAGE__->connection($make_dbictest_db::dsn);
39 package DBICTest::Schema::6;
40 use base qw/ DBIx::Class::Schema::Loader /;
41 __PACKAGE__->loader_options();
42 __PACKAGE__->connect($make_dbictest_db::dsn);
44 'make_schema_at' => sub {
45 use DBIx::Class::Schema::Loader qw/ make_schema_at /;
47 'DBICTest::Schema::7',
48 { really_erase_my_files => 1 },
49 [ $make_dbictest_db::dsn ],
51 DBICTest::Schema::7->clone;
53 'embedded_options' => sub {
54 package DBICTest::Schema::8;
55 use base qw/ DBIx::Class::Schema::Loader /;
57 $make_dbictest_db::dsn,
58 { loader_options => { really_erase_my_files => 1 } }
61 'embedded_options_in_attrs' => sub {
62 package DBICTest::Schema::9;
63 use base qw/ DBIx::Class::Schema::Loader /;
65 $make_dbictest_db::dsn,
68 { AutoCommit => 1, loader_options => { really_erase_my_files => 1 } }
71 'embedded_options_make_schema_at' => sub {
72 use DBIx::Class::Schema::Loader qw/ make_schema_at /;
74 'DBICTest::Schema::10',
77 $make_dbictest_db::dsn,
78 { loader_options => { really_erase_my_files => 1 } },
81 "DBICTest::Schema::10";
83 'almost_embedded' => sub {
84 package DBICTest::Schema::11;
85 use base qw/ DBIx::Class::Schema::Loader /;
86 __PACKAGE__->loader_options( really_erase_my_files => 1 );
88 $make_dbictest_db::dsn,
89 undef, undef, { AutoCommit => 1 }
92 'make_schema_at_explicit' => sub {
93 use DBIx::Class::Schema::Loader;
94 DBIx::Class::Schema::Loader::make_schema_at(
95 'DBICTest::Schema::12',
96 { really_erase_my_files => 1 },
97 [ $make_dbictest_db::dsn ],
99 DBICTest::Schema::12->clone;
103 # 4 tests per k/v pair
104 plan tests => 2 * @invocations;
106 while(@invocations >= 2) {
107 my $style = shift @invocations;
108 my $subref = shift @invocations;
109 test_schema($style, &$subref);