# Reload without unloading first to preserve any symbols from external
# packages.
- $self->_reload_classes(\@tables, { unload => 0 }) unless $self->dry_run;
+ $self->_reload_classes(\@tables, { unload => 0 });
# Drop temporary cache
delete $self->{_cache};
unshift @INC, $self->dump_directory;
+ return if $self->dry_run;
+
my @to_register;
my %have_source = map { $_ => $self->schema->source($_) }
$self->schema->sources;
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/,
],
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/,
options => {
dry_run => 1,
},
+ generated_results => [qw(Foo Bar)],
);
my $schema_file = $t->class_file('DBICTest::DumpMore::DryRun');
};
my $err = $@;
+ my $classes = !$err && $schema_class->loader->generated_classes;
+
Class::Unload->unload($schema_class);
_check_error($err, $tdata{error});
- return @warns;
+ return \@warns, $classes;
}
sub _dump_dbicdump {
_check_error($exception, $tdata{error});
}
- return @warnings;
+ return \@warnings;
}
sub _get_connect_info {
}
sub _test_dumps {
- my ($tdata, @warns) = @_;
+ my ($tdata, $warns, $classes) = @_;
my %tdata = %{$tdata};
my $schema_class = $tdata{classname};
my $check_warns = $tdata{warnings};
- is(@warns, @$check_warns, "$schema_class warning count")
- or diag @warns;
+ 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");
+ }
+
+ if ($classes && (my $results = $tdata{generated_results})) {
+ my $ns = $tdata{options}{use_namespaces} ? ("::".($tdata{result_namespace} || "Result")) : "";
+ is_deeply(
+ [ sort grep { $_ ne $schema_class } @$classes ],
+ [ sort map { "${schema_class}${ns}::$_" } @$results ],
+ "$schema_class generated_classes set correctly",
+ );
}
my $file_regexes = $tdata{regexes};