X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F23dumpmore.t;h=dd525969fd45318603d843f53af08b0a615e31b3;hb=7b0dce21c820b383d1018fa228000fe50af7f966;hp=b7b0da11837caabb7ab523c711c13bb71f68a11d;hpb=76e9a92a87d9a1f70179288c12f21a92a266d8dc;p=dbsrgits%2FDBIx-Class-Schema-Loader.git diff --git a/t/23dumpmore.t b/t/23dumpmore.t index b7b0da1..dd52596 100644 --- a/t/23dumpmore.t +++ b/t/23dumpmore.t @@ -387,6 +387,7 @@ $t->dump_test( constraint => [ [ qr/my_schema/ => qr/foo|bar/ ] ], exclude => [ [ qr/my_schema/ => qr/bar/ ] ], }, + generated_results => [qw(MySchema::Floop)], warnings => [ qr/^db_schema is not supported on SQLite/, ], @@ -404,6 +405,48 @@ $t->dump_test( }, ); +# test moniker_map + moniker_part_map +$t->dump_test( + classname => 'DBICTest::DumpMore::1', + options => { + db_schema => 'my_schema', + moniker_parts => ['_schema', 'name'], + moniker_part_separator => '::', + moniker_part_map => { + _schema => { + my_schema => 'OtherSchema', + }, + }, + moniker_map => { + my_schema => { + foo => 'MySchema::Floop', + }, + }, + qualify_objects => 1, + use_namespaces => 1, + }, + warnings => [ + qr/^db_schema is not supported on SQLite/, + ], + regexes => { + 'Result/MySchema/Floop' => [ + qr/^package DBICTest::DumpMore::1::Result::MySchema::Floop;/m, + qr/^\Q__PACKAGE__->table("my_schema.foo");\E/m, + # the has_many relname should not have the schema in it, but the class should + qr/^__PACKAGE__->has_many\(\n "bars",\n "DBICTest::DumpMore::1::Result::OtherSchema::Bar"/m, + ], + 'Result/OtherSchema/Bar' => [ + qr/^package DBICTest::DumpMore::1::Result::OtherSchema::Bar;/m, + qr/^\Q__PACKAGE__->table("my_schema.bar");\E/m, + # the has_many relname should not have the schema in it, but the class should + qr/^__PACKAGE__->belongs_to\(\n "fooref",\n "DBICTest::DumpMore::1::Result::MySchema::Floop"/m, + ], + + }, +); + + + $t->dump_test( classname => 'DBICTest::DumpMore::1', options => { @@ -534,6 +577,7 @@ $t->dump_test( options => { use_namespaces => 1, }, + generated_results => [qw(Foo Bar)], regexes => { 'Result/Foo' => [ qr/sub custom_method { 'custom_method works' }\n0;\n\n# You can replace.*\n1;\n\z/, @@ -541,5 +585,60 @@ $t->dump_test( }, ); +# test dry-run mode +$t->dump_test( + classname => 'DBICTest::DumpMore::DryRun', + options => { + dry_run => 1, + }, + generated_results => [qw(Foo Bar)], +); + +my $schema_file = $t->class_file('DBICTest::DumpMore::DryRun'); +ok( !-e $schema_file, "dry-run doesn't create file for schema class" ); +(my $schema_dir = $schema_file) =~ s/\.pm\z//; +ok( !-e $schema_dir, "dry-run doesn't create subdirectory for schema namespace" ); + +# test omit_version (RT#92300) +$t->dump_test( + classname => 'DBICTest::DumpMore::omit_version', + options => { + omit_version => 1, + }, + regexes => { + Foo => [ + qr/^\# Created by DBIx::Class::Schema::Loader @ \d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d$/m, + ], + }, +); + +# test omit_timestamp (RT#92300) +$t->dump_test( + classname => 'DBICTest::DumpMore::omit_timestamp', + options => { + omit_timestamp => 1, + }, + regexes => { + Foo => [ + qr/^\# Created by DBIx::Class::Schema::Loader v[\d.]+$/m, + ], + }, +); + +# test omit_version and omit_timestamp simultaneously (RT#92300) +$t->dump_test( + classname => 'DBICTest::DumpMore::omit_both', + options => { + omit_version => 1, + omit_timestamp => 1, + }, + # A positive regex here would match the top comment + neg_regexes => { + Foo => [ + qr/^\# Created by DBIx::Class::Schema::Loader.+$/m, + ], + }, +); + done_testing; # vim:et sts=4 sw=4 tw=0: