8 plan ( ($] >= 5.009000 and $] < 5.010001)
9 ? (skip_all => 'warnings::register broken under 5.10: http://rt.perl.org/rt3/Public/Bug/Display.html?id=62522')
15 local $SIG{__WARN__} = sub { push @w, @_ };
16 my $code = gen_code ( suffix => 1 );
18 ok (! $@, 'Eval code without warnings suppression')
21 ok ( (grep { $_ =~ /The many-to-many relationship bars is trying to create/ } @w), "Warning triggered without relevant 'no warnings'");
26 local $SIG{__WARN__} = sub { push @w, @_ };
28 my $code = gen_code ( suffix => 2, no_warn => 1 );
30 ok (! $@, 'Eval code with warnings suppression')
33 ok ( (not grep { $_ =~ /The many-to-many relationship bars is trying to create/ } @w), "No warning triggered with relevant 'no warnings'");
39 my $suffix = $args->{suffix};
40 my $no_warn = ( $args->{no_warn}
41 ? "no warnings 'DBIx::Class::Relationship::ManyToMany';"
51 DBICTest::Schema::Foo${suffix};
52 use base 'DBIx::Class::Core';
54 __PACKAGE__->table('foo');
55 __PACKAGE__->add_columns(
57 data_type => 'integer',
58 is_auto_increment => 1,
61 __PACKAGE__->set_primary_key('fooid');
64 __PACKAGE__->has_many('foo_to_bar' => 'DBICTest::Schema::FooToBar${suffix}' => 'bar');
65 __PACKAGE__->many_to_many( foos => foo_to_bar => 'bar' );
69 DBICTest::Schema::FooToBar${suffix};
71 use base 'DBIx::Class::Core';
72 __PACKAGE__->table('foo_to_bar');
73 __PACKAGE__->add_columns(
75 data_type => 'integer',
78 data_type => 'integer',
81 __PACKAGE__->belongs_to('foo' => 'DBICTest::Schema::Foo${suffix}');
82 __PACKAGE__->belongs_to('bar' => 'DBICTest::Schema::Foo${suffix}');
86 DBICTest::Schema::Bar${suffix};
88 use base 'DBIx::Class::Core';
90 __PACKAGE__->table('bar');
91 __PACKAGE__->add_columns(
93 data_type => 'integer',
94 is_auto_increment => 1,
99 __PACKAGE__->set_primary_key('barid');
100 __PACKAGE__->has_many('foo_to_bar' => 'DBICTest::Schema::FooToBar${suffix}' => 'foo');
102 __PACKAGE__->many_to_many( bars => foo_to_bar => 'foo' );