+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");
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',
NumExplodingSheep => 23
}
);
- };
- ok $@, $@;
+ } qr/isn't a Director/;
}
package Foo;
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;