No longer use rel_info($rel)->{class} in the cond resolver
[dbsrgits/DBIx-Class.git] / t / cdbi / 06-hasa.t
index 0fb3946..02933cd 100644 (file)
@@ -1,15 +1,8 @@
 use strict;
+use warnings;
 use Test::More;
-
-BEGIN {
-  eval "use DBIx::Class::CDBICompat;";
-  if ($@) {
-    plan (skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@");
-    next;
-  }
-  eval "use DBD::SQLite";
-  plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 24);
-}
+use Test::Exception;
+use DBIx::Class::_Util 'sigwarn_silencer';
 
 @YA::Film::ISA = 'Film';
 
@@ -114,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',
@@ -124,8 +118,7 @@ sub fail_with_bad_object {
         NumExplodingSheep => 23
       }
     );
-  };
-  ok $@, $@;
+  } qr/isn't a Director/;
 }
 
 package Foo;
@@ -161,10 +154,11 @@ my $bar = Bar->create({ id => 2, fav => 6 });
 isa_ok($bar->fav, "Foo");
 isa_ok($foo->fav, "Film");
 
-{ 
+{
   my $foo;
   Foo->add_trigger(after_create => sub { $foo = shift->fav });
   my $gwh = Foo->create({ id => 93, fav => 'Good Will Hunting' });
   isa_ok $foo, "Film", "Object in after_create trigger";
 }
 
+done_testing;