tables
class_to_table
uniq_to_primary
+ quiet
/);
__PACKAGE__->naming('v7');
+=head2 quiet
+
+If true, will not print the usual C<Dumping manual schema ... Schema dump
+completed.> messages. Does not affect warnings (except for warnings related to
+L</really_erase_my_files>.)
+
=head2 generate_pod
By default POD will be generated for columns and relationships, using database
if(!$self->skip_relationships) {
# The relationship loader needs a working schema
- $self->{quiet} = 1;
+ local $self->{quiet} = 1;
local $self->{dump_directory} = $self->{temp_directory};
$self->_reload_classes(\@tables);
$self->_load_relationships(\@tables);
- $self->{quiet} = 0;
# Remove that temp dir from INC so it doesn't get reloaded
@INC = grep $_ ne $self->dump_directory, @INC;
my $target_dir = $self->dump_directory;
warn "Dumping manual schema for $schema_class to directory $target_dir ...\n"
- unless $self->{dynamic} or $self->{quiet};
+ unless $self->dynamic or $self->quiet;
my $schema_text =
qq|package $schema_class;\n\n|
}
}
- warn "Schema dump completed.\n" unless $self->{dynamic} or $self->{quiet};
+ warn "Schema dump completed.\n" unless $self->dynamic or $self->quiet;
}
if (-f $filename && $self->really_erase_my_files) {
warn "Deleting existing file '$filename' due to "
- . "'really_erase_my_files' setting\n" unless $self->{quiet};
+ . "'really_erase_my_files' setting\n" unless $self->quiet;
unlink($filename);
}
# test loading external content
$t->dump_test(
classname => 'DBICTest::Schema::_no_skip_load_external',
- warnings => [
- qr/Dumping manual schema for DBICTest::Schema::_no_skip_load_external to directory /,
- qr/Schema dump completed/,
- ],
regexes => {
Foo => [
qr/package DBICTest::Schema::_no_skip_load_external::Foo;\nour \$skip_me = "bad mojo";\n1;/
$t->dump_test(
classname => 'DBICTest::Schema::_skip_load_external',
options => {
- skip_load_external => 1
+ skip_load_external => 1,
},
- warnings => [
- qr/Dumping manual schema for DBICTest::Schema::_skip_load_external to directory /,
- qr/Schema dump completed/,
- ],
neg_regexes => {
Foo => [
qr/package DBICTest::Schema::_skip_load_external::Foo;\nour \$skip_me = "bad mojo";\n1;/
$t->dump_test(
classname => 'DBICTest::Schema::_config_file',
options => { config_file => "$config_file" },
- warnings => [
- qr/Dumping manual schema for DBICTest::Schema::_config_file to directory /,
- qr/Schema dump completed/,
- ],
neg_regexes => {
Foo => [
qr/has_many/,
classname => 'DBICTest::Schema::_preserve_column_accessors',
test_db_class => 'make_dbictest_db_with_unique',
options => { naming => { column_accessors => 'preserve' } },
- warnings => [
- qr/Dumping manual schema for DBICTest::Schema::_preserve_column_accessors to directory /,
- qr/Schema dump completed/,
- ],
neg_regexes => {
RouteChange => [
qr/\baccessor\b/,
$t->dump_test(
classname => 'DBICTest::Schema::_sorted_rels',
test_db_class => 'make_dbictest_db_with_unique',
- warnings => [
- qr/Dumping manual schema for DBICTest::Schema::_sorted_rels to directory /,
- qr/Schema dump completed/,
- ],
regexes => {
Baz => [
qr/->might_have\(\n "quux".*->belongs_to\(\n "station_visited"/s,
$t->dump_test(
classname => 'DBICTest::Schema::_plural_monikers',
options => { naming => { monikers => 'plural' } },
- warnings => [
- qr/Dumping manual schema for DBICTest::Schema::_plural_monikers to directory /,
- qr/Schema dump completed/,
- ],
regexes => {
Foos => [
qr/\n=head1 NAME\n\nDBICTest::Schema::_plural_monikers::Foos\n\n=cut\n\n/,
classname => 'DBICTest::Schema::_singular_monikers',
test_db_class => 'make_dbictest_db_plural_tables',
options => { naming => { monikers => 'singular' } },
- warnings => [
- qr/Dumping manual schema for DBICTest::Schema::_singular_monikers to directory /,
- qr/Schema dump completed/,
- ],
regexes => {
Foo => [
qr/\n=head1 NAME\n\nDBICTest::Schema::_singular_monikers::Foo\n\n=cut\n\n/,
classname => 'DBICTest::Schema::_preserve_monikers',
test_db_class => 'make_dbictest_db_plural_tables',
options => { naming => { monikers => 'preserve' } },
- warnings => [
- qr/Dumping manual schema for DBICTest::Schema::_preserve_monikers to directory /,
- qr/Schema dump completed/,
- ],
regexes => {
Foos => [
qr/\n=head1 NAME\n\nDBICTest::Schema::_preserve_monikers::Foos\n\n=cut\n\n/,
left_base_classes => 'TestLeftBase',
components => [ 'TestComponent', '+TestComponentFQN' ],
},
- warnings => [
- qr/Dumping manual schema for DBICTest::DumpMore::1 to directory /,
- qr/Schema dump completed/,
- ],
regexes => {
schema => [
qr/package DBICTest::DumpMore::1;/,
$t->dump_test(
classname => 'DBICTest::DumpMore::1',
- warnings => [
- qr/Dumping manual schema for DBICTest::DumpMore::1 to directory /,
- qr/Schema dump completed/,
- ],
regexes => {
schema => [
qr/package DBICTest::DumpMore::1;/,
options => {
really_erase_my_files => 1
},
- warnings => [
- qr/Dumping manual schema for DBICTest::DumpMore::1 to directory /,
- qr/Deleting existing file /,
- qr/Deleting existing file /,
- qr/Deleting existing file /,
- qr/Schema dump completed/,
- ],
regexes => {
schema => [
qr/package DBICTest::DumpMore::1;/,
use_namespaces => 1,
generate_pod => 0
},
- warnings => [
- qr/Dumping manual schema for DBICTest::DumpMore::1 to directory /,
- qr/Schema dump completed/,
- ],
neg_regexes => {
'Result/Foo' => [
qr/^=/m,
qualify_objects => 1,
use_namespaces => 1
},
- warnings => [
- qr/Dumping manual schema for DBICTest::DumpMore::1 to directory /,
- qr/Schema dump completed/,
- ],
regexes => {
'Result/Foo' => [
qr/^\Q__PACKAGE__->table("foo_schema.foo");\E/m,
options => {
use_namespaces => 1
},
- warnings => [
- qr/Dumping manual schema for DBICTest::DumpMore::1 to directory /,
- qr/Schema dump completed/,
- ],
regexes => {
schema => [
qr/package DBICTest::DumpMore::1;/,
resultset_namespace => 'RSet',
default_resultset_class => 'RSetBase',
},
- warnings => [
- qr/Dumping manual schema for DBICTest::DumpMore::1 to directory /,
- qr/Schema dump completed/,
- ],
regexes => {
schema => [
qr/package DBICTest::DumpMore::1;/,
result_base_class => 'My::ResultBaseClass',
schema_base_class => 'My::SchemaBaseClass',
},
- warnings => [
- qr/Dumping manual schema for DBICTest::DumpMore::1 to directory /,
- qr/Schema dump completed/,
- ],
regexes => {
schema => [
qr/package DBICTest::DumpMore::1;/,
},
);
-
$t->dump_test(
classname => 'DBICTest::DumpMore::1',
options => {
'',
{ quote_char => '"' },
],
- warnings => [
- qr/Dumping manual schema for DBICTest::DumpMore::1 to directory /,
- qr/Schema dump completed/,
- ],
);
done_testing;
schema_base_class => 'My::SchemaBaseClass',
result_roles => ['TestRole', 'TestRole2'],
},
- warnings => [
- qr/Dumping manual schema for DBICTest::DumpMore::1 to directory /,
- qr/Schema dump completed/,
- ],
regexes => {
schema => [
qr/\nuse Moose;\nuse namespace::autoclean;\nextends 'My::SchemaBaseClass';\n\n/,
result_base_class => 'My::ResultBaseClass',
schema_base_class => 'My::SchemaBaseClass',
},
- warnings => [
- qr/Dumping manual schema for DBICTest::DumpMore::1 to directory /,
- qr/Schema dump completed/,
- ],
regexes => {
schema => [
qr/\nuse base 'My::SchemaBaseClass';\n/,
result_base_class => 'My::ResultBaseClass',
schema_base_class => 'My::SchemaBaseClass',
},
- warnings => [
- qr/Dumping manual schema for DBICTest::DumpMore::1 to directory /,
- qr/Schema dump completed/,
- ],
regexes => {
schema => [
qr/\nuse Moose;\nuse namespace::autoclean;\nextends 'My::SchemaBaseClass';\n\n/,
result_base_class => 'My::ResultBaseClass',
schema_base_class => 'My::SchemaBaseClass',
},
- warnings => [
- qr/Dumping manual schema for DBICTest::DumpMore::1 to directory /,
- qr/Schema dump completed/,
- ],
regexes => {
schema => [
qr/\nuse base 'My::SchemaBaseClass';\n/,
result_base_class => 'My::ResultBaseClass',
schema_base_class => 'My::SchemaBaseClass',
},
- warnings => [
- qr/Dumping manual schema for DBICTest::DumpMore::1 to directory /,
- qr/Schema dump completed/,
- ],
regexes => {
schema => [
qr/\nuse Moose;\nuse namespace::autoclean;\nextends 'My::SchemaBaseClass';\n\n/,
result_base_class => 'My::ResultBaseClass',
schema_base_class => 'My::SchemaBaseClass',
},
- warnings => [
- qr/Dumping manual schema for DBICTest::DumpMore::1 to directory /,
- ],
error => qr/\QIt is not possible to "downgrade" a schema that was loaded with use_moose => 1\E/,
);
no strict 'refs';
@{$schema_class . '::ISA'} = ('DBIx::Class::Schema::Loader');
- $schema_class->loader_options(%{$tdata{options}});
+ $schema_class->loader_options(
+ quiet => 1,
+ %{$tdata{options}},
+ );
my @warns;
eval {
# use $^X so we execute ./script/dbicdump with the same perl binary that the tests were executed with
my @cmd = ($^X, qw(script/dbicdump));
+ $tdata{options}{quiet} = 1 unless exists $tdata{options}{quiet};
+
while (my ($opt, $val) = each(%{ $tdata{options} })) {
$val = dumper_squashed $val if ref $val;
push @cmd, '-o', "$opt=$val";
is $got, $expected, 'error matches';
}
-
sub _test_dumps {
my ($tdata, @warns) = @_;
my $schema_class = $tdata{classname};
my $check_warns = $tdata{warnings};
- is(@warns, @$check_warns, "$schema_class warning count");
+
+ is(@warns, @$check_warns, "$schema_class warning count")
+ or diag @warns;
for(my $i = 0; $i <= $#$check_warns; $i++) {
- like($warns[$i], $check_warns->[$i], "$schema_class warning $i");
+ like(($warns[$i] || ''), $check_warns->[$i], "$schema_class warning $i");
}
my $file_regexes = $tdata{regexes};