6 local $SIG{__WARN__} = sub {
7 warn $_[0] unless $_[0] =~ /really_erase_my_files/
10 # Takes a $schema as input, runs 4 basic tests
12 my ($testname, $schema) = @_;
14 $schema = $schema->clone if !ref $schema;
15 isa_ok($schema, 'DBIx::Class::Schema', $testname);
17 my $foo_rs = $schema->resultset('Bar')->search({ barid => 3})->search_related('fooref');
18 isa_ok($foo_rs, 'DBIx::Class::ResultSet', $testname);
20 my $foo_first = $foo_rs->first;
21 like(ref $foo_first, qr/DBICTest::Schema::\d+::Foo/, $testname);
23 my $foo_first_text = $foo_first->footext;
24 is($foo_first_text, 'Foo record associated with the Bar with barid 3');
29 package DBICTest::Schema::5;
30 use base qw/ DBIx::Class::Schema::Loader /;
31 __PACKAGE__->connection($make_dbictest_db::dsn);
35 package DBICTest::Schema::6;
36 use base qw/ DBIx::Class::Schema::Loader /;
37 __PACKAGE__->loader_options();
38 __PACKAGE__->connect($make_dbictest_db::dsn);
40 'make_schema_at' => sub {
41 use DBIx::Class::Schema::Loader qw/ make_schema_at /;
43 'DBICTest::Schema::7',
44 { really_erase_my_files => 1 },
45 [ $make_dbictest_db::dsn ],
47 DBICTest::Schema::7->clone;
49 'embedded_options' => sub {
50 package DBICTest::Schema::8;
51 use base qw/ DBIx::Class::Schema::Loader /;
53 $make_dbictest_db::dsn,
54 { loader_options => { really_erase_my_files => 1 } }
57 'embedded_options_in_attrs' => sub {
58 package DBICTest::Schema::9;
59 use base qw/ DBIx::Class::Schema::Loader /;
61 $make_dbictest_db::dsn,
64 { AutoCommit => 1, loader_options => { really_erase_my_files => 1 } }
67 'embedded_options_make_schema_at' => sub {
68 use DBIx::Class::Schema::Loader qw/ make_schema_at /;
70 'DBICTest::Schema::10',
73 $make_dbictest_db::dsn,
74 { loader_options => { really_erase_my_files => 1 } },
77 "DBICTest::Schema::10";
79 'almost_embedded' => sub {
80 package DBICTest::Schema::11;
81 use base qw/ DBIx::Class::Schema::Loader /;
82 __PACKAGE__->loader_options( really_erase_my_files => 1 );
84 $make_dbictest_db::dsn,
85 undef, undef, { AutoCommit => 1 }
88 'make_schema_at_explicit' => sub {
89 use DBIx::Class::Schema::Loader;
90 DBIx::Class::Schema::Loader::make_schema_at(
91 'DBICTest::Schema::12',
92 { really_erase_my_files => 1 },
93 [ $make_dbictest_db::dsn ],
95 DBICTest::Schema::12->clone;
99 # 4 tests per k/v pair
100 plan tests => 2 * @invocations;
102 while(@invocations >= 2) {
103 my $style = shift @invocations;
104 my $subref = shift @invocations;
105 test_schema($style, &$subref);