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 # Takes a $schema as input, runs 4 basic tests
11 my ($testname, $schema) = @_;
13 $schema = $schema->clone if !ref $schema;
14 isa_ok($schema, 'DBIx::Class::Schema', $testname);
16 my $foo_rs = $schema->resultset('Bar')->search({ barid => 3})->search_related('fooref');
17 isa_ok($foo_rs, 'DBIx::Class::ResultSet', $testname);
19 my $foo_first = $foo_rs->first;
20 like(ref $foo_first, qr/DBICTest::Schema::\d+::Foo/, $testname);
22 my $foo_first_text = $foo_first->footext;
23 is($foo_first_text, 'Foo record associated with the Bar with barid 3');
28 package DBICTest::Schema::5;
29 use base qw/ DBIx::Class::Schema::Loader /;
30 __PACKAGE__->connection($make_dbictest_db::dsn);
34 package DBICTest::Schema::6;
35 use base qw/ DBIx::Class::Schema::Loader /;
36 __PACKAGE__->loader_options();
37 __PACKAGE__->connect($make_dbictest_db::dsn);
39 'make_schema_at' => sub {
40 use DBIx::Class::Schema::Loader qw/ make_schema_at /;
42 'DBICTest::Schema::7',
43 { really_erase_my_files => 1 },
44 [ $make_dbictest_db::dsn ],
46 DBICTest::Schema::7->clone;
48 'embedded_options' => sub {
49 package DBICTest::Schema::8;
50 use base qw/ DBIx::Class::Schema::Loader /;
52 $make_dbictest_db::dsn,
53 { loader_options => { really_erase_my_files => 1 } }
56 'embedded_options_in_attrs' => sub {
57 package DBICTest::Schema::9;
58 use base qw/ DBIx::Class::Schema::Loader /;
60 $make_dbictest_db::dsn,
63 { AutoCommit => 1, loader_options => { really_erase_my_files => 1 } }
66 'embedded_options_make_schema_at' => sub {
67 use DBIx::Class::Schema::Loader qw/ make_schema_at /;
69 'DBICTest::Schema::10',
72 $make_dbictest_db::dsn,
73 { loader_options => { really_erase_my_files => 1 } },
76 "DBICTest::Schema::10";
78 'almost_embedded' => sub {
79 package DBICTest::Schema::11;
80 use base qw/ DBIx::Class::Schema::Loader /;
81 __PACKAGE__->loader_options( really_erase_my_files => 1 );
83 $make_dbictest_db::dsn,
84 undef, undef, { AutoCommit => 1 }
87 'make_schema_at_explicit' => sub {
88 use DBIx::Class::Schema::Loader;
89 DBIx::Class::Schema::Loader::make_schema_at(
90 'DBICTest::Schema::12',
91 { really_erase_my_files => 1 },
92 [ $make_dbictest_db::dsn ],
94 DBICTest::Schema::12->clone;
98 # 4 tests per k/v pair
99 plan tests => 2 * @invocations;
101 while(@invocations >= 2) {
102 my $style = shift @invocations;
103 my $subref = shift @invocations;
104 test_schema($style, &$subref);