Merge the relationship resolution rework
[dbsrgits/DBIx-Class.git] / t / cdbi / 06-hasa.t
index 760a745..abad170 100644 (file)
@@ -1,23 +1,18 @@
+BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
+use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat';
+
 use strict;
-use Test::More;
+use warnings;
 
-BEGIN {
-  eval "use DBIx::Class::CDBICompat;";
-  if ($@) {
-    plan (skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@");
-  }
-  plan tests => 24;
-}
+use Test::More;
+use Test::Exception;
+use DBIx::Class::_Util 'sigwarn_silencer';
 
 @YA::Film::ISA = 'Film';
 
-#local $SIG{__WARN__} = sub { };
-
-INIT {
-  use lib 't/cdbi/testlib';
-  use Film;
-  use Director;
-}
+use lib 't/cdbi/testlib';
+use Film;
+use Director;
 
 Film->create_test_film;
 ok(my $btaste = Film->retrieve('Bad Taste'), "We have Bad Taste");
@@ -112,7 +107,8 @@ sub taste_bad {
 
 sub fail_with_bad_object {
   my ($dir, $codir) = @_;
-  eval {
+  throws_ok {
+    local $SIG{__WARN__} = sigwarn_silencer( qr/\Qusually should inherit from the related ResultClass ('Director')/ );
     YA::Film->create(
       {
         Title             => 'Tastes Bad',
@@ -122,8 +118,7 @@ sub fail_with_bad_object {
         NumExplodingSheep => 23
       }
     );
-  };
-  ok $@, $@;
+  } qr/is not a column on related source 'Director'/;
 }
 
 package Foo;
@@ -166,3 +161,4 @@ isa_ok($foo->fav, "Film");
   isa_ok $foo, "Film", "Object in after_create trigger";
 }
 
+done_testing;