DBIx-Class-Schema-Loader
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
t/backcompat/0.04006/lib/dbixcsl_common_tests.pm view on Meta::CPAN
package dbixcsl_common_tests;
use strict;
use warnings;
use Test::More;
use DBIx::Class::Schema::Loader;
use DBI;
sub new {
my $class = shift;
my $self;
if( ref($_[0]) eq 'HASH') {
my $args = shift;
$self = { (%$args) };
}
else {
$self = { @_ };
}
# Only MySQL uses this
$self->{innodb} ||= '';
$self->{verbose} = $ENV{TEST_VERBOSE} || 0;
return bless $self => $class;
}
sub skip_tests {
my ($self, $why) = @_;
plan skip_all => $why;
}
sub _monikerize {
my $name = shift;
return 'LoaderTest2X' if $name =~ /^loader_test2$/i;
return undef;
}
sub run_tests {
my $self = shift;
plan tests => 97;
$self->create();
my $schema_class = 'DBIXCSL_Test::Schema';
my $debug = ($self->{verbose} > 1) ? 1 : 0;
my @connect_info = ( $self->{dsn}, $self->{user}, $self->{password} );
my %loader_opts = (
constraint => qr/^(?:\S+\.)?loader_test[0-9]+$/i,
relationships => 1,
additional_classes => 'TestAdditional',
additional_base_classes => 'TestAdditionalBase',
left_base_classes => [ qw/TestLeftBase/ ],
components => [ qw/TestComponent/ ],
inflect_plural => { loader_test4 => 'loader_test4zes' },
inflect_singular => { fkid => 'fkid_singular' },
moniker_map => \&_monikerize,
debug => $debug,
);
$loader_opts{db_schema} = $self->{db_schema} if $self->{db_schema};
{
my @loader_warnings;
local $SIG{__WARN__} = sub { push(@loader_warnings, $_[0]); };
eval qq{
package $schema_class;
use base qw/DBIx::Class::Schema::Loader/;
__PACKAGE__->loader_options(\%loader_opts);
__PACKAGE__->connection(\@connect_info);
};
ok(!$@, "Loader initialization") or diag $@;
my $warn_count = 0;
$warn_count++ if grep /ResultSetManager/, @loader_warnings;
$warn_count++ if grep /Dynamic schema detected/, @loader_warnings;
$warn_count++ for grep /^Bad table or view/, @loader_warnings;
is(scalar(@loader_warnings), $warn_count)
or diag "Did not get the expected 0 warnings. Warnings are: "
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.758 second using v1.00-cache-2.02-grep-82fe00e-cpan-dad7e4baca0 )