8 use dbixcsl_dumper_tests;
9 my $t = 'dbixcsl_dumper_tests';
13 # test loading external content
15 classname => 'DBICTest::Schema::_no_skip_load_external',
17 qr/Dumping manual schema for DBICTest::Schema::_no_skip_load_external to directory /,
18 qr/Schema dump completed/,
22 qr/package DBICTest::Schema::_no_skip_load_external::Foo;\nour \$skip_me = "bad mojo";\n1;/
27 # test skipping external content
29 classname => 'DBICTest::Schema::_skip_load_external',
31 skip_load_external => 1
34 qr/Dumping manual schema for DBICTest::Schema::_skip_load_external to directory /,
35 qr/Schema dump completed/,
39 qr/package DBICTest::Schema::_skip_load_external::Foo;\nour \$skip_me = "bad mojo";\n1;/
47 my $config_file = File::Temp->new (UNLINK => 1);
49 print $config_file "{ skip_relationships => 1 }\n";
53 classname => 'DBICTest::Schema::_config_file',
54 options => { config_file => "$config_file" },
56 qr/Dumping manual schema for DBICTest::Schema::_config_file to directory /,
57 qr/Schema dump completed/,
69 classname => 'DBICTest::Schema::_clashing_monikers',
70 test_db_class => 'make_dbictest_db_clashing_monikers',
71 error => qr/tables 'bar', 'bars' reduced to the same source moniker 'Bar'/,
77 # test naming => { column_accessors => 'preserve' }
78 # also test POD for unique constraint
80 classname => 'DBICTest::Schema::_preserve_column_accessors',
81 test_db_class => 'make_dbictest_db_with_unique',
82 options => { naming => { column_accessors => 'preserve' } },
84 qr/Dumping manual schema for DBICTest::Schema::_preserve_column_accessors to directory /,
85 qr/Schema dump completed/,
94 qr/\n\n=head1 UNIQUE CONSTRAINTS\n\n=head2 C<baz_num_unique>\n\n=over 4\n\n=item \* L<\/baz_num>\n\n=back\n\n=cut\n\n__PACKAGE__->add_unique_constraint\("baz_num_unique"\, \["baz_num"\]\);\n\n/,
101 # test naming => { monikers => 'plural' }
103 classname => 'DBICTest::Schema::_plural_monikers',
104 options => { naming => { monikers => 'plural' } },
106 qr/Dumping manual schema for DBICTest::Schema::_plural_monikers to directory /,
107 qr/Schema dump completed/,
111 qr/\n=head1 NAME\n\nDBICTest::Schema::_plural_monikers::Foos\n\n=cut\n\n/,
114 qr/\n=head1 NAME\n\nDBICTest::Schema::_plural_monikers::Bars\n\n=cut\n\n/,
121 # test naming => { monikers => 'singular' }
123 classname => 'DBICTest::Schema::_singular_monikers',
124 test_db_class => 'make_dbictest_db_plural_tables',
125 options => { naming => { monikers => 'singular' } },
127 qr/Dumping manual schema for DBICTest::Schema::_singular_monikers to directory /,
128 qr/Schema dump completed/,
132 qr/\n=head1 NAME\n\nDBICTest::Schema::_singular_monikers::Foo\n\n=cut\n\n/,
135 qr/\n=head1 NAME\n\nDBICTest::Schema::_singular_monikers::Bar\n\n=cut\n\n/,
142 # test naming => { monikers => 'preserve' }
144 classname => 'DBICTest::Schema::_preserve_monikers',
145 test_db_class => 'make_dbictest_db_plural_tables',
146 options => { naming => { monikers => 'preserve' } },
148 qr/Dumping manual schema for DBICTest::Schema::_preserve_monikers to directory /,
149 qr/Schema dump completed/,
153 qr/\n=head1 NAME\n\nDBICTest::Schema::_preserve_monikers::Foos\n\n=cut\n\n/,
156 qr/\n=head1 NAME\n\nDBICTest::Schema::_preserve_monikers::Bars\n\n=cut\n\n/,
165 classname => 'DBICTest::DumpMore::1',
167 custom_column_info => sub {
168 my ($table, $col, $info) = @_;
169 return +{ extra => { is_footext => 1 } } if $col eq 'footext';
171 result_base_class => 'My::ResultBaseClass',
172 additional_classes => 'TestAdditional',
173 additional_base_classes => 'TestAdditionalBase',
174 left_base_classes => 'TestLeftBase',
175 components => [ 'TestComponent', '+TestComponentFQN' ],
178 qr/Dumping manual schema for DBICTest::DumpMore::1 to directory /,
179 qr/Schema dump completed/,
183 qr/package DBICTest::DumpMore::1;/,
187 qr/package DBICTest::DumpMore::1::Foo;/,
188 qr/\n=head1 NAME\n\nDBICTest::DumpMore::1::Foo\n\n=cut\n\nuse strict;\nuse warnings;\n\n/,
189 qr/\n=head1 BASE CLASS: L<My::ResultBaseClass>\n\n=cut\n\nuse base 'My::ResultBaseClass';\n\n/,
190 qr/\n=head1 ADDITIONAL CLASSES USED\n\n=over 4\n\n=item \* L<TestAdditional>\n\n=back\n\n=cut\n\n/,
191 qr/\n=head1 ADDITIONAL BASE CLASSES\n\n=over 4\n\n=item \* L<TestAdditionalBase>\n\n=back\n\n=cut\n\n/,
192 qr/\n=head1 LEFT BASE CLASSES\n\n=over 4\n\n=item \* L<TestLeftBase>\n\n=back\n\n=cut\n\n/,
193 qr/\n=head1 COMPONENTS LOADED\n\n=over 4\n\n=item \* L<DBIx::Class::TestComponent>\n\n=item \* L<TestComponentFQN>\n\n=back\n\n=cut\n\n/,
194 qr/\n=head1 TABLE: C<foo>\n\n=cut\n\n__PACKAGE__->table\("foo"\);\n\n/,
195 qr/\n=head1 ACCESSORS\n\n/,
196 qr/\n=head2 fooid\n\n data_type: 'integer'\n is_auto_increment: 1\n is_nullable: 0\n\n/,
197 qr/\n=head2 footext\n\n data_type: 'text'\n default_value: 'footext'\n extra: {is_footext => 1}\n is_nullable: 1\n\n/,
198 qr/\n=head1 PRIMARY KEY\n\n=over 4\n\n=item \* L<\/fooid>\n\n=back\n\n=cut\n\n__PACKAGE__->set_primary_key\("fooid"\);\n/,
199 qr/\n=head1 RELATIONS\n\n/,
200 qr/\n=head2 bars\n\nType: has_many\n\nRelated object: L<DBICTest::DumpMore::1::Bar>\n\n=cut\n\n/,
204 qr/package DBICTest::DumpMore::1::Bar;/,
205 qr/\n=head1 NAME\n\nDBICTest::DumpMore::1::Bar\n\n=cut\n\nuse strict;\nuse warnings;\n\n/,
206 qr/\n=head1 BASE CLASS: L<My::ResultBaseClass>\n\n=cut\n\nuse base 'My::ResultBaseClass';\n\n/,
207 qr/\n=head1 ADDITIONAL CLASSES USED\n\n=over 4\n\n=item \* L<TestAdditional>\n\n=back\n\n=cut\n\n/,
208 qr/\n=head1 ADDITIONAL BASE CLASSES\n\n=over 4\n\n=item \* L<TestAdditionalBase>\n\n=back\n\n=cut\n\n/,
209 qr/\n=head1 LEFT BASE CLASSES\n\n=over 4\n\n=item \* L<TestLeftBase>\n\n=back\n\n=cut\n\n/,
210 qr/\n=head1 COMPONENTS LOADED\n\n=over 4\n\n=item \* L<DBIx::Class::TestComponent>\n\n=item \* L<TestComponentFQN>\n\n=back\n\n=cut\n\n/,
211 qr/\n=head1 TABLE: C<bar>\n\n=cut\n\n__PACKAGE__->table\("bar"\);\n\n/,
212 qr/\n=head1 ACCESSORS\n\n/,
213 qr/\n=head2 barid\n\n data_type: 'integer'\n is_auto_increment: 1\n is_nullable: 0\n\n/,
214 qr/\n=head2 fooref\n\n data_type: 'integer'\n is_foreign_key: 1\n is_nullable: 1\n\n/,
215 qr/\n=head1 PRIMARY KEY\n\n=over 4\n\n=item \* L<\/barid>\n\n=back\n\n=cut\n\n__PACKAGE__->set_primary_key\("barid"\);\n/,
216 qr/\n=head1 RELATIONS\n\n/,
217 qr/\n=head2 fooref\n\nType: belongs_to\n\nRelated object: L<DBICTest::DumpMore::1::Foo>\n\n=cut\n\n/,
223 $t->append_to_class('DBICTest::DumpMore::1::Foo',q{# XXX This is my custom content XXX});
227 classname => 'DBICTest::DumpMore::1',
229 qr/Dumping manual schema for DBICTest::DumpMore::1 to directory /,
230 qr/Schema dump completed/,
234 qr/package DBICTest::DumpMore::1;/,
238 qr/package DBICTest::DumpMore::1::Foo;/,
239 qr/->set_primary_key/,
240 qr/1;\n# XXX This is my custom content XXX/,
243 qr/package DBICTest::DumpMore::1::Bar;/,
244 qr/->set_primary_key/,
252 classname => 'DBICTest::DumpMore::1',
254 really_erase_my_files => 1
257 qr/Dumping manual schema for DBICTest::DumpMore::1 to directory /,
258 qr/Deleting existing file /,
259 qr/Deleting existing file /,
260 qr/Deleting existing file /,
261 qr/Schema dump completed/,
265 qr/package DBICTest::DumpMore::1;/,
269 qr/package DBICTest::DumpMore::1::Foo;/,
270 qr/->set_primary_key/,
274 qr/package DBICTest::DumpMore::1::Bar;/,
275 qr/->set_primary_key/,
281 qr/# XXX This is my custom content XXX/,
291 classname => 'DBICTest::DumpMore::1',
297 qr/Dumping manual schema for DBICTest::DumpMore::1 to directory /,
298 qr/Schema dump completed/,
309 classname => 'DBICTest::DumpMore::1',
311 db_schema => 'foo_schema',
312 qualify_objects => 1,
316 qr/Dumping manual schema for DBICTest::DumpMore::1 to directory /,
317 qr/Schema dump completed/,
321 qr/^\Q__PACKAGE__->table("foo_schema.foo");\E/m,
322 # the has_many relname should not have the schema in it!
323 qr/^__PACKAGE__->has_many\(\n "bars"/m,
329 classname => 'DBICTest::DumpMore::1',
334 qr/Dumping manual schema for DBICTest::DumpMore::1 to directory /,
335 qr/Schema dump completed/,
339 qr/package DBICTest::DumpMore::1;/,
340 qr/->load_namespaces/,
343 qr/package DBICTest::DumpMore::1::Result::Foo;/,
344 qr/->set_primary_key/,
348 qr/package DBICTest::DumpMore::1::Result::Bar;/,
349 qr/->set_primary_key/,
357 classname => 'DBICTest::DumpMore::1',
360 result_namespace => 'Res',
361 resultset_namespace => 'RSet',
362 default_resultset_class => 'RSetBase',
365 qr/Dumping manual schema for DBICTest::DumpMore::1 to directory /,
366 qr/Schema dump completed/,
370 qr/package DBICTest::DumpMore::1;/,
371 qr/->load_namespaces/,
372 qr/result_namespace => "Res"/,
373 qr/resultset_namespace => "RSet"/,
374 qr/default_resultset_class => "RSetBase"/,
377 qr/package DBICTest::DumpMore::1::Res::Foo;/,
378 qr/->set_primary_key/,
382 qr/package DBICTest::DumpMore::1::Res::Bar;/,
383 qr/->set_primary_key/,
391 classname => 'DBICTest::DumpMore::1',
394 result_namespace => '+DBICTest::DumpMore::1::Res',
395 resultset_namespace => 'RSet',
396 default_resultset_class => 'RSetBase',
397 result_base_class => 'My::ResultBaseClass',
398 schema_base_class => 'My::SchemaBaseClass',
401 qr/Dumping manual schema for DBICTest::DumpMore::1 to directory /,
402 qr/Schema dump completed/,
406 qr/package DBICTest::DumpMore::1;/,
407 qr/->load_namespaces/,
408 qr/result_namespace => "\+DBICTest::DumpMore::1::Res"/,
409 qr/resultset_namespace => "RSet"/,
410 qr/default_resultset_class => "RSetBase"/,
411 qr/use base 'My::SchemaBaseClass'/,
414 qr/package DBICTest::DumpMore::1::Res::Foo;/,
415 qr/use base 'My::ResultBaseClass'/,
416 qr/->set_primary_key/,
420 qr/package DBICTest::DumpMore::1::Res::Bar;/,
421 qr/use base 'My::ResultBaseClass'/,
422 qr/->set_primary_key/,
430 classname => 'DBICTest::DumpMore::1',
433 result_base_class => 'My::MissingResultBaseClass',
435 error => qr/My::MissingResultBaseClass.*is not installed/,
438 # test quote_char in connect_info for dbicdump
440 classname => 'DBICTest::DumpMore::1',
441 extra_connect_info => [
444 { quote_char => '"' },
447 qr/Dumping manual schema for DBICTest::DumpMore::1 to directory /,
448 qr/Schema dump completed/,
453 # vim:et sts=4 sw=4 tw=0: