THROWAWAY: Don't load unmodified generated external classes
[dbsrgits/DBIx-Class-Schema-Loader.git] / t / 23dumpmore.t
CommitLineData
605fcea8 1use strict;
b564fc4b 2use warnings;
71130750 3use Test::More;
b564fc4b 4use DBIx::Class::Schema::Loader::Utils qw/slurp_file write_file/;
5use namespace::clean;
6use File::Temp ();
71130750 7use lib qw(t/lib);
bac32da1 8use dbixcsl_test_dir '$tdir';
71130750 9use dbixcsl_dumper_tests;
10my $t = 'dbixcsl_dumper_tests';
a4187fdf 11
71130750 12$t->cleanup;
a4187fdf 13
6dde4613 14# test loading external content
71130750 15$t->dump_test(
494e0205 16 classname => 'DBICTest::Schema::_no_skip_load_external',
17 regexes => {
18 Foo => [
19 qr/package DBICTest::Schema::_no_skip_load_external::Foo;.*\nour \$skip_me = "bad mojo";\n1;/s
20 ],
21 },
6dde4613 22);
23
24# test skipping external content
71130750 25$t->dump_test(
494e0205 26 classname => 'DBICTest::Schema::_skip_load_external',
27 options => {
28 skip_load_external => 1,
29 },
30 neg_regexes => {
31 Foo => [
32 qr/package DBICTest::Schema::_skip_load_external::Foo;.*\nour \$skip_me = "bad mojo";\n1;/s
33 ],
34 },
6dde4613 35);
36
71130750 37$t->cleanup;
73099af4 38# test config_file
71130750 39{
494e0205 40 my $config_file = File::Temp->new (UNLINK => 1);
41
42 print $config_file "{ skip_relationships => 1 }\n";
43 close $config_file;
44
45 $t->dump_test(
46 classname => 'DBICTest::Schema::_config_file',
47 options => { config_file => "$config_file" },
48 neg_regexes => {
49 Foo => [
50 qr/has_many/,
51 ],
52 },
53 );
71130750 54}
c9cf9b4d 55
71130750 56# proper exception
57$t->dump_test(
494e0205 58 classname => 'DBICTest::Schema::_clashing_monikers',
59 test_db_class => 'make_dbictest_db_clashing_monikers',
60 error => qr/tables (?:"bar", "bars"|"bars", "bar") reduced to the same source moniker 'Bar'/,
c9cf9b4d 61);
62
c9cf9b4d 63
71130750 64$t->cleanup;
c9cf9b4d 65
c0a0986f 66# test naming => { column_accessors => 'preserve' }
8007f3a7 67# also test POD for unique constraint
c0a0986f 68$t->dump_test(
69 classname => 'DBICTest::Schema::_preserve_column_accessors',
70 test_db_class => 'make_dbictest_db_with_unique',
71 options => { naming => { column_accessors => 'preserve' } },
c0a0986f 72 neg_regexes => {
73 RouteChange => [
74 qr/\baccessor\b/,
75 ],
76 },
8007f3a7 77 regexes => {
78 Baz => [
79 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/,
80 ],
81 }
c0a0986f 82);
83
84$t->cleanup;
85
b33d5949 86# test that rels are sorted
87$t->dump_test(
88 classname => 'DBICTest::Schema::_sorted_rels',
89 test_db_class => 'make_dbictest_db_with_unique',
b33d5949 90 regexes => {
91 Baz => [
92 qr/->might_have\(\n "quux".*->belongs_to\(\n "station_visited"/s,
93 ],
94 }
95);
96
97$t->cleanup;
98
6d358d58 99$t->dump_test(
100 classname => 'DBICTest::Schema::_sorted_uniqs',
101 test_db_class => 'make_dbictest_db_multi_unique',
102 regexes => {
103 Bar => [
104 qr/->add_unique_constraint\("uniq1_unique".*->add_unique_constraint\("uniq2_unique"/s,
105 ],
106 },
107);
108
109$t->cleanup;
110
c0a0986f 111# test naming => { monikers => 'plural' }
112$t->dump_test(
113 classname => 'DBICTest::Schema::_plural_monikers',
114 options => { naming => { monikers => 'plural' } },
c0a0986f 115 regexes => {
116 Foos => [
117 qr/\n=head1 NAME\n\nDBICTest::Schema::_plural_monikers::Foos\n\n=cut\n\n/,
118 ],
119 Bars => [
120 qr/\n=head1 NAME\n\nDBICTest::Schema::_plural_monikers::Bars\n\n=cut\n\n/,
121 ],
122 },
123);
124
125$t->cleanup;
126
127# test naming => { monikers => 'singular' }
128$t->dump_test(
129 classname => 'DBICTest::Schema::_singular_monikers',
130 test_db_class => 'make_dbictest_db_plural_tables',
131 options => { naming => { monikers => 'singular' } },
c0a0986f 132 regexes => {
133 Foo => [
134 qr/\n=head1 NAME\n\nDBICTest::Schema::_singular_monikers::Foo\n\n=cut\n\n/,
135 ],
136 Bar => [
137 qr/\n=head1 NAME\n\nDBICTest::Schema::_singular_monikers::Bar\n\n=cut\n\n/,
138 ],
139 },
140);
141
142$t->cleanup;
143
144# test naming => { monikers => 'preserve' }
145$t->dump_test(
146 classname => 'DBICTest::Schema::_preserve_monikers',
147 test_db_class => 'make_dbictest_db_plural_tables',
148 options => { naming => { monikers => 'preserve' } },
c0a0986f 149 regexes => {
150 Foos => [
151 qr/\n=head1 NAME\n\nDBICTest::Schema::_preserve_monikers::Foos\n\n=cut\n\n/,
152 ],
153 Bars => [
154 qr/\n=head1 NAME\n\nDBICTest::Schema::_preserve_monikers::Bars\n\n=cut\n\n/,
155 ],
156 },
157);
158
159$t->cleanup;
160
c6c8787c 161# test out the POD and "use utf8;"
71130750 162$t->dump_test(
494e0205 163 classname => 'DBICTest::DumpMore::1',
164 options => {
165 custom_column_info => sub {
166 my ($table, $col, $info) = @_;
167 return +{ extra => { is_footext => 1 } } if $col eq 'footext';
168 },
169 result_base_class => 'My::ResultBaseClass',
170 additional_classes => 'TestAdditional',
171 additional_base_classes => 'TestAdditionalBase',
172 left_base_classes => 'TestLeftBase',
173 components => [ 'TestComponent', '+TestComponentFQN' ],
174 },
175 regexes => {
176 schema => [
177 qr/^use utf8;\n/,
178 qr/package DBICTest::DumpMore::1;/,
179 qr/->load_classes/,
180 ],
181 Foo => [
182 qr/^use utf8;\n/,
183 qr/package DBICTest::DumpMore::1::Foo;/,
184 qr/\n=head1 NAME\n\nDBICTest::DumpMore::1::Foo\n\n=cut\n\nuse strict;\nuse warnings;\n\n/,
185 qr/\n=head1 BASE CLASS: L<My::ResultBaseClass>\n\n=cut\n\nuse base 'My::ResultBaseClass';\n\n/,
186 qr/\n=head1 ADDITIONAL CLASSES USED\n\n=over 4\n\n=item \* L<TestAdditional>\n\n=back\n\n=cut\n\n/,
187 qr/\n=head1 ADDITIONAL BASE CLASSES\n\n=over 4\n\n=item \* L<TestAdditionalBase>\n\n=back\n\n=cut\n\n/,
188 qr/\n=head1 LEFT BASE CLASSES\n\n=over 4\n\n=item \* L<TestLeftBase>\n\n=back\n\n=cut\n\n/,
189 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/,
190 qr/\n=head1 TABLE: C<foo>\n\n=cut\n\n__PACKAGE__->table\("foo"\);\n\n/,
191 qr/\n=head1 ACCESSORS\n\n/,
192 qr/\n=head2 fooid\n\n data_type: 'integer'\n is_auto_increment: 1\n is_nullable: 0\n\n/,
193 qr/\n=head2 footext\n\n data_type: 'text'\n default_value: 'footext'\n extra: \{is_footext => 1\}\n is_nullable: 1\n\n/,
194 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/,
195 qr/\n=head1 RELATIONS\n\n/,
196 qr/\n=head2 bars\n\nType: has_many\n\nRelated object: L<DBICTest::DumpMore::1::Bar>\n\n=cut\n\n/,
197 qr/1;\n$/,
198 ],
199 Bar => [
200 qr/^use utf8;\n/,
201 qr/package DBICTest::DumpMore::1::Bar;/,
202 qr/\n=head1 NAME\n\nDBICTest::DumpMore::1::Bar\n\n=cut\n\nuse strict;\nuse warnings;\n\n/,
203 qr/\n=head1 BASE CLASS: L<My::ResultBaseClass>\n\n=cut\n\nuse base 'My::ResultBaseClass';\n\n/,
204 qr/\n=head1 ADDITIONAL CLASSES USED\n\n=over 4\n\n=item \* L<TestAdditional>\n\n=back\n\n=cut\n\n/,
205 qr/\n=head1 ADDITIONAL BASE CLASSES\n\n=over 4\n\n=item \* L<TestAdditionalBase>\n\n=back\n\n=cut\n\n/,
206 qr/\n=head1 LEFT BASE CLASSES\n\n=over 4\n\n=item \* L<TestLeftBase>\n\n=back\n\n=cut\n\n/,
207 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/,
208 qr/\n=head1 TABLE: C<bar>\n\n=cut\n\n__PACKAGE__->table\("bar"\);\n\n/,
209 qr/\n=head1 ACCESSORS\n\n/,
210 qr/\n=head2 barid\n\n data_type: 'integer'\n is_auto_increment: 1\n is_nullable: 0\n\n/,
211 qr/\n=head2 fooref\n\n data_type: 'integer'\n is_foreign_key: 1\n is_nullable: 1\n\n/,
212 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/,
213 qr/\n=head1 RELATIONS\n\n/,
214 qr/\n=head2 fooref\n\nType: belongs_to\n\nRelated object: L<DBICTest::DumpMore::1::Foo>\n\n=cut\n\n/,
215 qr/\n1;\n$/,
216 ],
217 },
c9cf9b4d 218);
219
71130750 220$t->append_to_class('DBICTest::DumpMore::1::Foo',q{# XXX This is my custom content XXX});
f812ef60 221
9de8c789 222
71130750 223$t->dump_test(
494e0205 224 classname => 'DBICTest::DumpMore::1',
225 regexes => {
226 schema => [
227 qr/package DBICTest::DumpMore::1;/,
228 qr/->load_classes/,
229 ],
230 Foo => [
231 qr/package DBICTest::DumpMore::1::Foo;/,
232 qr/->set_primary_key/,
233 qr/1;\n# XXX This is my custom content XXX/,
234 ],
235 Bar => [
236 qr/package DBICTest::DumpMore::1::Bar;/,
237 qr/->set_primary_key/,
238 qr/1;\n$/,
239 ],
240 },
a4187fdf 241);
242
a4187fdf 243
71130750 244$t->dump_test(
494e0205 245 classname => 'DBICTest::DumpMore::1',
246 options => {
247 really_erase_my_files => 1
248 },
249 regexes => {
250 schema => [
251 qr/package DBICTest::DumpMore::1;/,
252 qr/->load_classes/,
253 ],
254 Foo => [
255 qr/package DBICTest::DumpMore::1::Foo;/,
256 qr/->set_primary_key/,
257 qr/1;\n$/,
258 ],
259 Bar => [
260 qr/package DBICTest::DumpMore::1::Bar;/,
261 qr/->set_primary_key/,
262 qr/1;\n$/,
263 ],
264 },
265 neg_regexes => {
266 Foo => [
267 qr/# XXX This is my custom content XXX/,
268 ],
269 },
492dce8d 270);
271
eac5494b 272
71130750 273$t->cleanup;
274
275# test namespaces
276$t->dump_test(
494e0205 277 classname => 'DBICTest::DumpMore::1',
278 options => {
279 use_namespaces => 1,
280 generate_pod => 0
281 },
282 neg_regexes => {
283 'Result/Foo' => [
284 qr/^=/m,
285 ],
286 },
a4187fdf 287);
605fcea8 288
eac5494b 289
71130750 290$t->dump_test(
494e0205 291 classname => 'DBICTest::DumpMore::1',
292 options => {
293 db_schema => 'foo_schema',
294 qualify_objects => 1,
295 use_namespaces => 1
296 },
297 warnings => [
298 qr/^db_schema is not supported on SQLite/,
69219349 299 ],
494e0205 300 regexes => {
301 'Result/Foo' => [
302 qr/^\Q__PACKAGE__->table("foo_schema.foo");\E/m,
303 # the has_many relname should not have the schema in it!
304 qr/^__PACKAGE__->has_many\(\n "bars"/m,
305 ],
306 },
69219349 307);
308
9890b10c 309# test qualify_objects
310$t->dump_test(
494e0205 311 classname => 'DBICTest::DumpMore::1',
312 options => {
313 db_schema => [ 'foo_schema', 'bar_schema' ],
314 qualify_objects => 0,
315 use_namespaces => 1,
316 },
317 warnings => [
318 qr/^db_schema is not supported on SQLite/,
9890b10c 319 ],
494e0205 320 regexes => {
321 'Result/Foo' => [
322 # the table name should not include the db schema
323 qr/^\Q__PACKAGE__->table("foo");\E/m,
324 ],
325 'Result/Bar' => [
326 # the table name should not include the db schema
327 qr/^\Q__PACKAGE__->table("bar");\E/m,
328 ],
329 },
9890b10c 330);
331
c4a69b87 332# test moniker_parts
333$t->dump_test(
494e0205 334 classname => 'DBICTest::DumpMore::1',
335 options => {
336 db_schema => 'my_schema',
337 moniker_parts => ['_schema', 'name'],
338 qualify_objects => 1,
339 use_namespaces => 1,
340 },
341 warnings => [
342 qr/^db_schema is not supported on SQLite/,
848731a7 343 ],
494e0205 344 regexes => {
345 'Result/MySchemaFoo' => [
346 qr/^\Q__PACKAGE__->table("my_schema.foo");\E/m,
347 # the has_many relname should not have the schema in it, but the class should
348 qr/^__PACKAGE__->has_many\(\n "bars",\n "DBICTest::DumpMore::1::Result::MySchemaBar"/m,
349 ],
350 },
848731a7 351);
352
353# test moniker_part_separator
354$t->dump_test(
494e0205 355 classname => 'DBICTest::DumpMore::1',
356 options => {
357 db_schema => 'my_schema',
358 moniker_parts => ['_schema', 'name'],
359 moniker_part_separator => '::',
360 qualify_objects => 1,
361 use_namespaces => 1,
362 },
363 warnings => [
364 qr/^db_schema is not supported on SQLite/,
c4a69b87 365 ],
494e0205 366 regexes => {
367 'Result/MySchema/Foo' => [
368 qr/^package DBICTest::DumpMore::1::Result::MySchema::Foo;/m,
369 qr/^\Q__PACKAGE__->table("my_schema.foo");\E/m,
370 # the has_many relname should not have the schema in it, but the class should
371 qr/^__PACKAGE__->has_many\(\n "bars",\n "DBICTest::DumpMore::1::Result::MySchema::Bar"/m,
372 ],
373 },
c4a69b87 374);
375
b187901e 376# test moniker_part_separator + moniker_map + recursive constraints
fc972571 377$t->dump_test(
494e0205 378 classname => 'DBICTest::DumpMore::1',
379 options => {
380 db_schema => 'my_schema',
381 moniker_parts => ['_schema', 'name'],
382 moniker_part_separator => '::',
383 qualify_objects => 1,
384 use_namespaces => 1,
385 moniker_map => {
386 my_schema => { foo => "MySchema::Floop" },
387 },
388 constraint => [ [ qr/my_schema/ => qr/foo|bar/ ] ],
389 exclude => [ [ qr/my_schema/ => qr/bar/ ] ],
390 },
391 generated_results => [qw(MySchema::Floop)],
392 warnings => [
393 qr/^db_schema is not supported on SQLite/,
fc972571 394 ],
494e0205 395 regexes => {
396 'Result/MySchema/Floop' => [
397 qr/^package DBICTest::DumpMore::1::Result::MySchema::Floop;/m,
398 qr/^\Q__PACKAGE__->table("my_schema.foo");\E/m,
399 ],
400 },
401 neg_regexes => {
402 'Result/MySchema/Floop' => [
403 # the bar table should not be loaded, so no relationship should exist
404 qr/^__PACKAGE__->has_many\(\n "bars"/m,
405 ],
406 },
fc972571 407);
408
392d1c58 409# test moniker_map + moniker_part_map
410$t->dump_test(
494e0205 411 classname => 'DBICTest::DumpMore::1',
412 options => {
413 db_schema => 'my_schema',
414 moniker_parts => ['_schema', 'name'],
415 moniker_part_separator => '::',
416 moniker_part_map => {
417 _schema => {
418 my_schema => 'OtherSchema',
419 },
392d1c58 420 },
494e0205 421 moniker_map => {
422 my_schema => {
423 foo => 'MySchema::Floop',
424 },
392d1c58 425 },
494e0205 426 qualify_objects => 1,
427 use_namespaces => 1,
392d1c58 428 },
494e0205 429 warnings => [
430 qr/^db_schema is not supported on SQLite/,
392d1c58 431 ],
494e0205 432 regexes => {
433 'Result/MySchema/Floop' => [
434 qr/^package DBICTest::DumpMore::1::Result::MySchema::Floop;/m,
435 qr/^\Q__PACKAGE__->table("my_schema.foo");\E/m,
436 # the has_many relname should not have the schema in it, but the class should
437 qr/^__PACKAGE__->has_many\(\n "bars",\n "DBICTest::DumpMore::1::Result::OtherSchema::Bar"/m,
438 ],
439 'Result/OtherSchema/Bar' => [
440 qr/^package DBICTest::DumpMore::1::Result::OtherSchema::Bar;/m,
441 qr/^\Q__PACKAGE__->table("my_schema.bar");\E/m,
442 # the has_many relname should not have the schema in it, but the class should
443 qr/^__PACKAGE__->belongs_to\(\n "fooref",\n "DBICTest::DumpMore::1::Result::MySchema::Floop"/m,
444 ],
392d1c58 445
494e0205 446 },
392d1c58 447);
448
449
450
71130750 451$t->dump_test(
494e0205 452 classname => 'DBICTest::DumpMore::1',
453 options => {
454 use_namespaces => 1
455 },
456 regexes => {
457 schema => [
458 qr/package DBICTest::DumpMore::1;/,
459 qr/->load_namespaces/,
460 ],
461 'Result/Foo' => [
462 qr/package DBICTest::DumpMore::1::Result::Foo;/,
463 qr/->set_primary_key/,
464 qr/1;\n$/,
465 ],
466 'Result/Bar' => [
467 qr/package DBICTest::DumpMore::1::Result::Bar;/,
468 qr/->set_primary_key/,
469 qr/1;\n$/,
470 ],
471 },
f44ecc2f 472);
473
eac5494b 474
71130750 475$t->dump_test(
494e0205 476 classname => 'DBICTest::DumpMore::1',
477 options => {
478 use_namespaces => 1,
479 result_namespace => 'Res',
480 resultset_namespace => 'RSet',
481 default_resultset_class => 'RSetBase',
482 },
483 regexes => {
484 schema => [
485 qr/package DBICTest::DumpMore::1;/,
486 qr/->load_namespaces/,
487 qr/result_namespace => "Res"/,
488 qr/resultset_namespace => "RSet"/,
489 qr/default_resultset_class => "RSetBase"/,
490 ],
491 'Res/Foo' => [
492 qr/package DBICTest::DumpMore::1::Res::Foo;/,
493 qr/->set_primary_key/,
494 qr/1;\n$/,
495 ],
496 'Res/Bar' => [
497 qr/package DBICTest::DumpMore::1::Res::Bar;/,
498 qr/->set_primary_key/,
499 qr/1;\n$/,
500 ],
501 },
f44ecc2f 502);
503
eac5494b 504
71130750 505$t->dump_test(
494e0205 506 classname => 'DBICTest::DumpMore::1',
507 options => {
508 use_namespaces => 1,
509 result_namespace => '+DBICTest::DumpMore::1::Res',
510 resultset_namespace => 'RSet',
511 default_resultset_class => 'RSetBase',
512 result_base_class => 'My::ResultBaseClass',
513 schema_base_class => 'My::SchemaBaseClass',
514 },
515 regexes => {
516 schema => [
517 qr/package DBICTest::DumpMore::1;/,
518 qr/->load_namespaces/,
519 qr/result_namespace => "\+DBICTest::DumpMore::1::Res"/,
520 qr/resultset_namespace => "RSet"/,
521 qr/default_resultset_class => "RSetBase"/,
522 qr/use base 'My::SchemaBaseClass'/,
523 ],
524 'Res/Foo' => [
525 qr/package DBICTest::DumpMore::1::Res::Foo;/,
526 qr/use base 'My::ResultBaseClass'/,
527 qr/->set_primary_key/,
528 qr/1;\n$/,
529 ],
530 'Res/Bar' => [
531 qr/package DBICTest::DumpMore::1::Res::Bar;/,
532 qr/use base 'My::ResultBaseClass'/,
533 qr/->set_primary_key/,
534 qr/1;\n$/,
535 ],
536 },
f44ecc2f 537);
c634fde9 538
71130750 539$t->dump_test(
494e0205 540 classname => 'DBICTest::DumpMore::1',
541 options => {
542 use_namespaces => 1,
543 result_base_class => 'My::MissingResultBaseClass',
544 },
545 error => qr/My::MissingResultBaseClass.*is not installed/,
8048320c 546);
f44ecc2f 547
667f1a0b 548# test quote_char in connect_info for dbicdump
549$t->dump_test(
494e0205 550 classname => 'DBICTest::DumpMore::1',
551 extra_connect_info => [
552 '',
553 '',
554 { quote_char => '"' },
555 ],
667f1a0b 556);
557
b564fc4b 558# test fix for RT#70507 (end comment and 1; gets lost if left with actual
559# custom content)
560
561$t->dump_test(
562 classname => 'DBICTest::DumpMore::Upgrade',
563 options => {
564 use_namespaces => 0,
565 },
566);
567
568my $file = $t->class_file('DBICTest::DumpMore::Upgrade::Foo');
569
570my $code = slurp_file $file;
571
572$code =~ s/(?=# You can replace)/sub custom_method { 'custom_method works' }\n0;\n\n/;
573
574write_file $file, $code;
575
576$t->dump_test(
577 classname => 'DBICTest::DumpMore::Upgrade',
578 options => {
579 use_namespaces => 1,
580 },
f56e3f73 581 generated_results => [qw(Foo Bar)],
b564fc4b 582 regexes => {
583 'Result/Foo' => [
7c304e59 584 qr/sub custom_method \{ 'custom_method works' \}\n0;\n\n# You can replace.*\n1;\n\z/,
b564fc4b 585 ],
586 },
587);
588
28310f24 589# test dry-run mode
590$t->dump_test(
591 classname => 'DBICTest::DumpMore::DryRun',
592 options => {
593 dry_run => 1,
594 },
f56e3f73 595 generated_results => [qw(Foo Bar)],
28310f24 596);
597
598my $schema_file = $t->class_file('DBICTest::DumpMore::DryRun');
599ok( !-e $schema_file, "dry-run doesn't create file for schema class" );
600(my $schema_dir = $schema_file) =~ s/\.pm\z//;
601ok( !-e $schema_dir, "dry-run doesn't create subdirectory for schema namespace" );
602
c43d9f47 603# test omit_version (RT#92300)
604$t->dump_test(
605 classname => 'DBICTest::DumpMore::omit_version',
606 options => {
494e0205 607 omit_version => 1,
c43d9f47 608 },
609 regexes => {
494e0205 610 Foo => [
611 qr/^\# Created by DBIx::Class::Schema::Loader @ \d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d$/m,
612 ],
c43d9f47 613 },
614);
615
616# test omit_timestamp (RT#92300)
617$t->dump_test(
618 classname => 'DBICTest::DumpMore::omit_timestamp',
619 options => {
494e0205 620 omit_timestamp => 1,
c43d9f47 621 },
622 regexes => {
494e0205 623 Foo => [
624 qr/^\# Created by DBIx::Class::Schema::Loader v[\d.]+$/m,
625 ],
c43d9f47 626 },
627);
628
629# test omit_version and omit_timestamp simultaneously (RT#92300)
630$t->dump_test(
631 classname => 'DBICTest::DumpMore::omit_both',
632 options => {
494e0205 633 omit_version => 1,
634 omit_timestamp => 1,
c43d9f47 635 },
636 # A positive regex here would match the top comment
637 neg_regexes => {
494e0205 638 Foo => [
639 qr/^\# Created by DBIx::Class::Schema::Loader.+$/m,
640 ],
c43d9f47 641 },
642);
643
bac32da1 644my $copy = $t->copy_class('DBICTest::DumpMore::1::Foo', 'dump_copy');
645diag $copy;
646unshift @INC, "$tdir/dump_copy";
647
648$t->dump_test(
649 classname => 'DBICTest::DumpMore::1',
650 neg_regexes => {
651 Foo => [
652 qr/^# These lines were loaded from/m,
653 ],
654 },
655);
656
657$t->append_to_class('DBICTest::DumpMore::1::Foo', qq{# XXX This is my external custom content\n}, 'dump_copy');
658
659$t->dump_test(
660 classname => 'DBICTest::DumpMore::1',
661 options => {
662 really_erase_my_files => 1,
663 },
664 regexes => {
665 Foo => [
666 qr/^# XXX This is my external custom content/m,
667 ],
668 },
669 neg_regexes => {
670 Foo => [
671 qr/^# These lines were loaded from.*^# Created by DBIx::Class::Schema::Loader/,
672 ],
673 },
674);
675
676
d27f2b7b 677done_testing;
c0a0986f 678# vim:et sts=4 sw=4 tw=0: