6 # Takes a $schema as input, runs 4 basic tests
8 my ($testname, $schema) = @_;
10 $schema = $schema->clone if !ref $schema;
11 isa_ok($schema, 'DBIx::Class::Schema', $testname);
13 my $foo_rs = $schema->resultset('Bar')->search({ barid => 3})->search_related('fooref');
14 isa_ok($foo_rs, 'DBIx::Class::ResultSet', $testname);
16 my $foo_first = $foo_rs->first;
17 like(ref $foo_first, qr/DBICTest::Schema::\d+::Foo/, $testname);
19 my $foo_first_text = $foo_first->footext;
20 is($foo_first_text, 'Foo record associated with the Bar with barid 3');
25 package DBICTest::Schema::5;
26 use base qw/ DBIx::Class::Schema::Loader /;
27 __PACKAGE__->connection($make_dbictest_db::dsn);
31 package DBICTest::Schema::6;
32 use base qw/ DBIx::Class::Schema::Loader /;
33 __PACKAGE__->loader_options();
34 __PACKAGE__->connect($make_dbictest_db::dsn);
36 'make_schema_at' => sub {
37 use DBIx::Class::Schema::Loader qw/ make_schema_at /;
39 'DBICTest::Schema::7',
40 { really_erase_my_files => 1 },
41 [ $make_dbictest_db::dsn ],
43 DBICTest::Schema::7->clone;
45 'embedded_options' => sub {
46 package DBICTest::Schema::8;
47 use base qw/ DBIx::Class::Schema::Loader /;
49 $make_dbictest_db::dsn,
50 { loader_options => { really_erase_my_files => 1 } }
53 'embedded_options_in_attrs' => sub {
54 package DBICTest::Schema::9;
55 use base qw/ DBIx::Class::Schema::Loader /;
57 $make_dbictest_db::dsn,
60 { AutoCommit => 1, loader_options => { really_erase_my_files => 1 } }
63 'embedded_options_make_schema_at' => sub {
64 use DBIx::Class::Schema::Loader qw/ make_schema_at /;
66 'DBICTest::Schema::10',
69 $make_dbictest_db::dsn,
70 { loader_options => { really_erase_my_files => 1 } },
73 "DBICTest::Schema::10";
75 'almost_embedded' => sub {
76 package DBICTest::Schema::11;
77 use base qw/ DBIx::Class::Schema::Loader /;
78 __PACKAGE__->loader_options( really_erase_my_files => 1 );
80 $make_dbictest_db::dsn,
81 undef, undef, { AutoCommit => 1 }
84 'make_schema_at_explicit' => sub {
85 use DBIx::Class::Schema::Loader;
86 DBIx::Class::Schema::Loader::make_schema_at(
87 'DBICTest::Schema::12',
88 { really_erase_my_files => 1 },
89 [ $make_dbictest_db::dsn ],
91 DBICTest::Schema::12->clone;
95 # 4 tests per k/v pair
96 plan tests => 2 * @invocations;
98 while(@invocations >= 2) {
99 my $style = shift @invocations;
100 my $subref = shift @invocations;
101 test_schema($style, &$subref);