6 $SIG{__WARN__} = sub { }; # Suppress warnings, as we test a lot of deprecated stuff here
8 # Takes a $schema as input, runs 4 basic tests
10 my ($testname, $schema) = @_;
12 $schema = $schema->clone if !ref $schema;
13 isa_ok($schema, 'DBIx::Class::Schema', $testname);
15 my $foo_rs = $schema->resultset('Bar')->search({ barid => 3})->search_related('fooref');
16 isa_ok($foo_rs, 'DBIx::Class::ResultSet', $testname);
18 my $foo_first = $foo_rs->first;
19 like(ref $foo_first, qr/DBICTest::Schema::\d+::Foo/, $testname);
21 my $foo_first_text = $foo_first->footext;
22 is($foo_first_text, 'Foo record associated with the Bar with barid 3');
26 'deprecated_one' => sub {
27 package DBICTest::Schema::1;
28 use base qw/ DBIx::Class::Schema::Loader /;
29 __PACKAGE__->connection($make_dbictest_db::dsn);
30 __PACKAGE__->load_from_connection( relationships => 1 );
33 'deprecated_two' => sub {
34 package DBICTest::Schema::2;
35 use base qw/ DBIx::Class::Schema::Loader /;
36 __PACKAGE__->load_from_connection(
38 connect_info => [ $make_dbictest_db::dsn ],
42 'deprecated_three' => sub {
43 package DBICTest::Schema::3;
44 use base qw/ DBIx::Class::Schema::Loader /;
45 __PACKAGE__->load_from_connection(
47 dsn => $make_dbictest_db::dsn,
51 'deprecated_four' => sub {
52 package DBICTest::Schema::4;
53 use base qw/ DBIx::Class::Schema::Loader /;
54 __PACKAGE__->connection($make_dbictest_db::dsn);
55 __PACKAGE__->loader_options( relationships => 1 );
59 package DBICTest::Schema::5;
60 use base qw/ DBIx::Class::Schema::Loader /;
61 __PACKAGE__->loader_options( relationships => 1 );
62 __PACKAGE__->connection($make_dbictest_db::dsn);
66 package DBICTest::Schema::6;
67 use base qw/ DBIx::Class::Schema::Loader /;
68 __PACKAGE__->loader_options( relationships => 1 );
69 __PACKAGE__->connect($make_dbictest_db::dsn);
71 'make_schema_at' => sub {
72 use DBIx::Class::Schema::Loader qw/ make_schema_at /;
74 'DBICTest::Schema::7',
75 { relationships => 1 },
76 [ $make_dbictest_db::dsn ],
78 DBICTest::Schema::7->clone;
80 'embedded_options' => sub {
81 package DBICTest::Schema::8;
82 use base qw/ DBIx::Class::Schema::Loader /;
84 $make_dbictest_db::dsn,
85 { loader_options => { relationships => 1 } }
88 'embedded_options_in_attrs' => sub {
89 package DBICTest::Schema::9;
90 use base qw/ DBIx::Class::Schema::Loader /;
92 $make_dbictest_db::dsn,
95 { AutoCommit => 1, loader_options => { relationships => 1 } }
98 'embedded_options_make_schema_at' => sub {
99 use DBIx::Class::Schema::Loader qw/ make_schema_at /;
101 'DBICTest::Schema::10',
104 $make_dbictest_db::dsn,
105 { loader_options => { relationships => 1 } },
108 "DBICTest::Schema::10";
110 'almost_embedded' => sub {
111 package DBICTest::Schema::11;
112 use base qw/ DBIx::Class::Schema::Loader /;
113 __PACKAGE__->loader_options( relationships => 1 );
114 __PACKAGE__->connect(
115 $make_dbictest_db::dsn,
116 undef, undef, { AutoCommit => 1 }
119 'make_schema_at_explicit' => sub {
120 use DBIx::Class::Schema::Loader;
121 DBIx::Class::Schema::Loader::make_schema_at(
122 'DBICTest::Schema::12',
123 { relationships => 1 },
124 [ $make_dbictest_db::dsn ],
126 DBICTest::Schema::12->clone;
130 # 4 tests per k/v pair
131 plan tests => 2 * @invocations;
133 while(@invocations >= 2) {
134 my $style = shift @invocations;
135 my $subref = shift @invocations;
136 test_schema($style, &$subref);