Fix moniker_map callback test for upcasing databases (e.g. Oracle)
[dbsrgits/DBIx-Class-Schema-Loader.git] / t / lib / dbixcsl_common_tests.pm
index 9c92e07..fb5239c 100644 (file)
@@ -12,7 +12,7 @@ use DBI;
 use Digest::MD5;
 use File::Find 'find';
 use Class::Unload ();
-use DBIx::Class::Schema::Loader::Utils qw/dumper_squashed slurp_file/;
+use DBIx::Class::Schema::Loader::Utils qw/dumper_squashed slurp_file sigwarn_silencer/;
 use List::MoreUtils 'apply';
 use DBIx::Class::Schema::Loader::Optional::Dependencies ();
 use Try::Tiny;
@@ -88,8 +88,11 @@ sub skip_tests {
 
 sub _monikerize {
     my $name = shift;
-    return 'LoaderTest2X' if $name =~ /^loader_test2$/i;
-    return undef;
+    my $orig = pop;
+    return $orig->({
+        loader_test2 => 'LoaderTest2X',
+        LOADER_TEST2 => 'LoaderTest2X',
+    });
 }
 
 sub run_tests {
@@ -1094,7 +1097,7 @@ qr/\n__PACKAGE__->(?:belongs_to|has_many|might_have|has_one|many_to_many)\(
 
         # relname is preserved when another fk is added
         {
-            local $SIG{__WARN__} = sub { warn @_ unless $_[0] =~ /invalidates \d+ active statement/ };
+            local $SIG{__WARN__} = sigwarn_silencer(qr/invalidates \d+ active statement/);
             $conn->storage->disconnect; # for mssql and access
         }
 
@@ -1264,12 +1267,10 @@ TODO: {
 
         my $guard = $conn->txn_scope_guard;
 
-        my $warn_handler = $SIG{__WARN__} || sub { warn @_ };
-        local $SIG{__WARN__} = sub {
-            $warn_handler->(@_)
-                unless $_[0] =~ RESCAN_WARNINGS
-                    || $_[0] =~ /commit ineffective with AutoCommit enabled/; # FIXME
-        };
+        my $rescan_warnings = RESCAN_WARNINGS;
+        local $SIG{__WARN__} = sigwarn_silencer(
+            qr/$rescan_warnings|commit ineffective with AutoCommit enabled/ # FIXME
+        );
 
         my $schema_from = DBIx::Class::Schema::Loader::make_schema_at(
             "TestSchemaFromAnother", \%opts, [ sub { $conn->storage->dbh } ]
@@ -2307,7 +2308,7 @@ sub setup_data_type_tests {
 sub rescan_without_warnings {
     my ($self, $conn) = @_;
 
-    local $SIG{__WARN__} = sub { warn @_ unless $_[0] =~ RESCAN_WARNINGS };
+    local $SIG{__WARN__} = sigwarn_silencer(RESCAN_WARNINGS);
     return $conn->rescan;
 }