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__->naming('current');
32 __PACKAGE__->connection($make_dbictest_db::dsn);
36 package DBICTest::Schema::6;
37 use base qw/ DBIx::Class::Schema::Loader /;
38 __PACKAGE__->loader_options();
39 __PACKAGE__->naming('current');
40 __PACKAGE__->connect($make_dbictest_db::dsn);
42 'make_schema_at' => sub {
43 use DBIx::Class::Schema::Loader qw/ make_schema_at /;
45 'DBICTest::Schema::7',
46 { really_erase_my_files => 1, naming => 'current' },
47 [ $make_dbictest_db::dsn ],
49 DBICTest::Schema::7->clone;
51 'embedded_options' => sub {
52 package DBICTest::Schema::8;
53 use base qw/ DBIx::Class::Schema::Loader /;
54 __PACKAGE__->naming('current');
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 /;
63 __PACKAGE__->naming('current');
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,
79 really_erase_my_files => 1,
84 "DBICTest::Schema::10";
86 'almost_embedded' => sub {
87 package DBICTest::Schema::11;
88 use base qw/ DBIx::Class::Schema::Loader /;
89 __PACKAGE__->loader_options(
90 really_erase_my_files => 1,
94 $make_dbictest_db::dsn,
95 undef, undef, { AutoCommit => 1 }
98 'make_schema_at_explicit' => sub {
99 use DBIx::Class::Schema::Loader;
100 DBIx::Class::Schema::Loader::make_schema_at(
101 'DBICTest::Schema::12',
102 { really_erase_my_files => 1, naming => 'current' },
103 [ $make_dbictest_db::dsn ],
105 DBICTest::Schema::12->clone;
109 # 4 tests per k/v pair
110 plan tests => 2 * @invocations;
112 while(@invocations >= 2) {
113 my $style = shift @invocations;
114 my $subref = shift @invocations;
115 test_schema($style, &$subref);