Introducing DBIx::Class::Schema::SanityChecker
[dbsrgits/DBIx-Class.git] / t / cdbi / DeepAbstractSearch / 01_search.t
old mode 100755 (executable)
new mode 100644 (file)
index 3db333e..5c87cb0
@@ -1,30 +1,42 @@
+BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
+use DBIx::Class::Optional::Dependencies -skip_all_without => qw( cdbicompat Class::DBI::Plugin::DeepAbstractSearch>=0 );
+
 use strict;
+use warnings;
+
 use Test::More;
 
-BEGIN {
-    eval "use DBIx::Class::CDBICompat;";
-    if ($@) {
-        plan (skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@");
-        next;
-    }
-
-    plan skip_all => 'needs DBD::SQLite for testing'
-        unless eval { require DBD::SQLite };
-    
-    plan skip_all => 'needs Class::DBI::Plugin::DeepAbstractSearch'
-        unless eval { require Class::DBI::Plugin::DeepAbstractSearch };
-    
-    plan tests => 19;
-}
+use DBICTest;
+
+my $DB = DBICTest->_sqlite_dbname(sqlite_use_file => 1);;
 
-my $DB  = "t/var/cdbi_testdb";
-unlink $DB if -e $DB;
+# not usre why this test needs an AutoCommit => 0 and a commit further
+# down - EDONOTCARE
+$ENV{DBIC_UNSAFE_AUTOCOMMIT_OK} = 1;
 
 my @DSN = ("dbi:SQLite:dbname=$DB", '', '', { AutoCommit => 0 });
 
 package Music::DBI;
 use base qw(DBIx::Class::CDBICompat);
 use Class::DBI::Plugin::DeepAbstractSearch;
+
+BEGIN {
+  # offset the warning from DBIx::Class::Schema on 5.8
+  # keep the ::Schema default as-is otherwise
+  DBIx::Class::_ENV_::OLD_MRO
+    and
+  ( eval <<'EOS' or die $@ );
+
+  sub setup_schema_instance {
+    my $s = shift->next::method(@_);
+    $s->schema_sanity_checker('');
+    $s;
+  }
+
+  1;
+EOS
+}
+
 __PACKAGE__->connection(@DSN);
 
 my $sql = <<'SQL_END';
@@ -297,5 +309,4 @@ package main;
             "CDs from Sony or Supraphon";
 }
 
-END { unlink $DB if -e $DB }
-
+done_testing;