X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F103many_to_many_warning.t;h=2c42091bff48f748860c2c5b387fb2b62aedc941;hb=c200d94979bde5ac74070d3e898927433b0e667c;hp=a8f790a5a154496821821b367d4f61b5514747f6;hpb=52cf2a38ca19df2a49bc4d061efab7f2cb92d83f;p=dbsrgits%2FDBIx-Class.git diff --git a/t/103many_to_many_warning.t b/t/103many_to_many_warning.t index a8f790a..2c42091 100644 --- a/t/103many_to_many_warning.t +++ b/t/103many_to_many_warning.t @@ -3,44 +3,41 @@ use warnings; use Test::More; use lib qw(t/lib); -use Data::Dumper; +use DBICTest; -plan ( ($] >= 5.009000 and $] < 5.010001) - ? (skip_all => 'warnings::register broken under 5.10: http://rt.perl.org/rt3/Public/Bug/Display.html?id=62522') - : (tests => 4) -); +my $exp_warn = qr/The many-to-many relationship 'bars' is trying to create/; { - my @w; - local $SIG{__WARN__} = sub { push @w, @_ }; + my @w; + local $SIG{__WARN__} = sub { $_[0] =~ $exp_warn ? push @w, $_[0] : warn $_[0] }; my $code = gen_code ( suffix => 1 ); + + local $ENV{DBIC_OVERWRITE_HELPER_METHODS_OK}; eval "$code"; ok (! $@, 'Eval code without warnings suppression') || diag $@; - ok ( (grep { $_ =~ /The many-to-many relationship bars is trying to create/ } @w), "Warning triggered without relevant 'no warnings'"); + ok (@w, "Warning triggered without DBIC_OVERWRITE_HELPER_METHODS_OK"); } { - my @w; - local $SIG{__WARN__} = sub { push @w, @_ }; + my @w; + local $SIG{__WARN__} = sub { $_[0] =~ $exp_warn ? push @w, $_[0] : warn $_[0] }; + + my $code = gen_code ( suffix => 2 ); - my $code = gen_code ( suffix => 2, no_warn => 1 ); + local $ENV{DBIC_OVERWRITE_HELPER_METHODS_OK} = 1; eval "$code"; ok (! $@, 'Eval code with warnings suppression') || diag $@; - ok ( (not grep { $_ =~ /The many-to-many relationship bars is trying to create/ } @w), "No warning triggered with relevant 'no warnings'"); + ok (! @w, "No warning triggered with DBIC_OVERWRITE_HELPER_METHODS_OK"); } sub gen_code { my $args = { @_ }; my $suffix = $args->{suffix}; - my $no_warn = ( $args->{no_warn} - ? "no warnings 'DBIx::Class::Relationship::ManyToMany';" - : '', - ); return <set_primary_key('barid'); __PACKAGE__->has_many('foo_to_bar' => 'DBICTest::Schema::FooToBar${suffix}' => 'foo'); @@ -106,3 +102,5 @@ use warnings; EOF } + +done_testing;