3 use lib qw(t/backcompat/0.04006/lib);
6 plan skip_all => 'set SCHEMA_LOADER_TESTS_BACKCOMPAT to enable these tests'
7 unless $ENV{SCHEMA_LOADER_TESTS_BACKCOMPAT};
9 local $SIG{__WARN__} = sub {
10 warn @_ unless $_[0] =~ /Dynamic schema|really_erase_my_files/;
13 # Takes a $schema as input, runs 4 basic tests
15 my ($testname, $schema) = @_;
17 $schema = $schema->clone if !ref $schema;
18 isa_ok($schema, 'DBIx::Class::Schema', $testname);
20 my $foo_rs = $schema->resultset('Bar')->search({ barid => 3})->search_related('fooref');
21 isa_ok($foo_rs, 'DBIx::Class::ResultSet', $testname);
23 my $foo_first = $foo_rs->first;
24 like(ref $foo_first, qr/DBICTest::Schema::\d+::Foo/, $testname);
26 my $foo_first_text = $foo_first->footext;
27 is($foo_first_text, 'Foo record associated with the Bar with barid 3');
32 package DBICTest::Schema::5;
33 use base qw/ DBIx::Class::Schema::Loader /;
34 __PACKAGE__->connection($make_dbictest_db::dsn);
38 package DBICTest::Schema::6;
39 use base qw/ DBIx::Class::Schema::Loader /;
40 __PACKAGE__->loader_options();
41 __PACKAGE__->connect($make_dbictest_db::dsn);
43 'make_schema_at' => sub {
44 use DBIx::Class::Schema::Loader qw/ make_schema_at /;
46 'DBICTest::Schema::7',
47 { really_erase_my_files => 1 },
48 [ $make_dbictest_db::dsn ],
50 DBICTest::Schema::7->clone;
52 'embedded_options' => sub {
53 package DBICTest::Schema::8;
54 use base qw/ DBIx::Class::Schema::Loader /;
56 $make_dbictest_db::dsn,
57 { loader_options => { really_erase_my_files => 1 } }
60 'embedded_options_in_attrs' => sub {
61 package DBICTest::Schema::9;
62 use base qw/ DBIx::Class::Schema::Loader /;
64 $make_dbictest_db::dsn,
67 { AutoCommit => 1, loader_options => { really_erase_my_files => 1 } }
70 'embedded_options_make_schema_at' => sub {
71 use DBIx::Class::Schema::Loader qw/ make_schema_at /;
73 'DBICTest::Schema::10',
76 $make_dbictest_db::dsn,
77 { loader_options => { really_erase_my_files => 1 } },
80 "DBICTest::Schema::10";
82 'almost_embedded' => sub {
83 package DBICTest::Schema::11;
84 use base qw/ DBIx::Class::Schema::Loader /;
85 __PACKAGE__->loader_options( really_erase_my_files => 1 );
87 $make_dbictest_db::dsn,
88 undef, undef, { AutoCommit => 1 }
91 'make_schema_at_explicit' => sub {
92 use DBIx::Class::Schema::Loader;
93 DBIx::Class::Schema::Loader::make_schema_at(
94 'DBICTest::Schema::12',
95 { really_erase_my_files => 1 },
96 [ $make_dbictest_db::dsn ],
98 DBICTest::Schema::12->clone;
102 # 4 tests per k/v pair
103 plan tests => 2 * @invocations;
105 while(@invocations >= 2) {
106 my $style = shift @invocations;
107 my $subref = shift @invocations;
108 test_schema($style, &$subref);