our $no_warn = "";
+our $suffix = "";
plan tests => 2;
{
local $@;
local $SIG{__WARN__} = sub { die @_ };
eval "@{[code()]}";
- ok($@, "Warning triggered without relevant 'no warnings'");
+ like($@, qr/The many-to-many relationship bars/,
+ "Warning triggered without relevant 'no warnings'");
}
{
- # Clean up the packages
- delete $INC{'DBICTest/ManyToManyWarning.pm'};
- delete $DBICTest::{"Schema::"};
$no_warn = "no warnings 'DBIx::Class::Relationship::ManyToMany';";
+ $suffix = "2";
local $SIG{__WARN__} = sub { die @_ };
eval "@{[code()]}";
- ok(!$@, "No Warning triggered with relevant 'no warnings'");
+ unlike($@, qr/The many-to-many relationship bars.*?Bar2/s,
+ "No warning triggered with relevant 'no warnings'");
}
sub code {
{
package #
- DBICTest::Schema::Foo;
+ DBICTest::Schema::Foo$suffix;
use base 'DBIx::Class::Core';
__PACKAGE__->table('foo');
__PACKAGE__->add_columns(
__PACKAGE__->set_primary_key('fooid');
- __PACKAGE__->has_many('foo_to_bar' => 'DBICTest::Schema::FooToBar' => 'bar');
+ __PACKAGE__->has_many('foo_to_bar' => 'DBICTest::Schema::FooToBar$main::suffix' => 'bar');
__PACKAGE__->many_to_many( foos => foo_to_bar => 'bar' );
}
{
package #
- DBICTest::Schema::FooToBar;
+ DBICTest::Schema::FooToBar$suffix;
use base 'DBIx::Class::Core';
__PACKAGE__->table('foo_to_bar');
data_type => 'integer',
},
);
- __PACKAGE__->belongs_to('foo' => 'DBICTest::Schema::Foo');
- __PACKAGE__->belongs_to('bar' => 'DBICTest::Schema::Foo');
+ __PACKAGE__->belongs_to('foo' => 'DBICTest::Schema::Foo$main::suffix');
+ __PACKAGE__->belongs_to('bar' => 'DBICTest::Schema::Foo$main::suffix');
}
{
package #
- DBICTest::Schema::Bar;
+ DBICTest::Schema::Bar$suffix;
use base 'DBIx::Class::Core';
__PACKAGE__->table('bar');
__PACKAGE__->add_columns(
use DBIx::Class::Relationship::ManyToMany;
$main::no_warn
__PACKAGE__->set_primary_key('barid');
- __PACKAGE__->has_many('foo_to_bar' => 'DBICTest::Schema::FooToBar' => 'foo');
+ __PACKAGE__->has_many('foo_to_bar' => 'DBICTest::Schema::FooToBar$main::suffix' => 'foo');
__PACKAGE__->many_to_many( bars => foo_to_bar => 'foo' );
sub add_to_bars {}
+ die $main::suffix;
}
EOF
return $file;