X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fcdbi%2F06-hasa.t;h=6d47c1232cfeb097eb8d7f0fa896f48e21fdc25b;hb=73f54e275e7dc98b4a082475ff252afdbeca182f;hp=8cc830159dc0b18d6f41f79bc8392e8fcd880ce3;hpb=68de943862f06cabd397d2e74d12cd9cdc999779;p=dbsrgits%2FDBIx-Class.git diff --git a/t/cdbi/06-hasa.t b/t/cdbi/06-hasa.t index 8cc8301..6d47c12 100644 --- a/t/cdbi/06-hasa.t +++ b/t/cdbi/06-hasa.t @@ -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/isn't a Director/; } package Foo; @@ -159,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;