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');
24 'deprecated_one' => sub {
25 package DBICTest::Schema::1;
26 use base qw/ DBIx::Class::Schema::Loader /;
27 __PACKAGE__->connection($make_dbictest_db::dsn);
28 __PACKAGE__->load_from_connection( relationships => 1 );
31 'deprecated_two' => sub {
32 package DBICTest::Schema::2;
33 use base qw/ DBIx::Class::Schema::Loader /;
34 __PACKAGE__->load_from_connection(
36 connect_info => [ $make_dbictest_db::dsn ],
40 'deprecated_three' => sub {
41 package DBICTest::Schema::3;
42 use base qw/ DBIx::Class::Schema::Loader /;
43 __PACKAGE__->load_from_connection(
45 dsn => $make_dbictest_db::dsn,
49 'deprecated_four' => sub {
50 package DBICTest::Schema::4;
51 use base qw/ DBIx::Class::Schema::Loader /;
52 __PACKAGE__->connection($make_dbictest_db::dsn);
53 __PACKAGE__->loader_options( relationships => 1 );
57 package DBICTest::Schema::5;
58 use base qw/ DBIx::Class::Schema::Loader /;
59 __PACKAGE__->loader_options( relationships => 1 );
60 __PACKAGE__->connection($make_dbictest_db::dsn);
64 package DBICTest::Schema::6;
65 use base qw/ DBIx::Class::Schema::Loader /;
66 __PACKAGE__->loader_options( relationships => 1 );
67 __PACKAGE__->connect($make_dbictest_db::dsn);
69 'make_schema_at' => sub {
70 use DBIx::Class::Schema::Loader qw/ make_schema_at /;
72 'DBICTest::Schema::7',
73 { relationships => 1 },
74 [ $make_dbictest_db::dsn ],
76 DBICTest::Schema::7->clone;
78 'embedded_options' => sub {
79 package DBICTest::Schema::8;
80 use base qw/ DBIx::Class::Schema::Loader /;
82 $make_dbictest_db::dsn,
83 { loader_options => { relationships => 1 } }
86 'embedded_options_in_attrs' => sub {
87 package DBICTest::Schema::9;
88 use base qw/ DBIx::Class::Schema::Loader /;
90 $make_dbictest_db::dsn,
93 { AutoCommit => 1, loader_options => { relationships => 1 } }
96 'embedded_options_make_schema_at' => sub {
97 use DBIx::Class::Schema::Loader qw/ make_schema_at /;
99 'DBICTest::Schema::10',
102 $make_dbictest_db::dsn,
103 { loader_options => { relationships => 1 } },
106 "DBICTest::Schema::10";
108 'almost_embedded' => sub {
109 package DBICTest::Schema::11;
110 use base qw/ DBIx::Class::Schema::Loader /;
111 __PACKAGE__->loader_options( relationships => 1 );
112 __PACKAGE__->connect(
113 $make_dbictest_db::dsn,
114 undef, undef, { AutoCommit => 1 }
117 'make_schema_at_explicit' => sub {
118 use DBIx::Class::Schema::Loader;
119 DBIx::Class::Schema::Loader::make_schema_at(
120 'DBICTest::Schema::12',
121 { relationships => 1 },
122 [ $make_dbictest_db::dsn ],
124 DBICTest::Schema::12->clone;
128 # 4 tests per k/v pair
129 plan tests => 2 * @invocations;
131 while(@invocations >= 2) {
132 my $style = shift @invocations;
133 my $subref = shift @invocations;
134 test_schema($style, &$subref);