12 local $SIG{__WARN__} = sub { push @w, @_ };
14 my $code = gen_code ( suffix => 1 );
17 ok ( (grep { $_ =~ /The many-to-many relationship bars is trying to create/ } @w), "Warning triggered without relevant 'no warnings'");
22 local $SIG{__WARN__} = sub { push @w, @_ };
24 my $code = gen_code ( suffix => 2, no_warn => 1 );
29 ok ( (not grep { $_ =~ /The many-to-many relationship bars is trying to create/ } @w), "No warning triggered with relevant 'no warnings'");
35 my $suffix = $args->{suffix};
36 my $no_warn = ( $args->{no_warn}
37 ? "no warnings 'DBIx::Class::Relationship::ManyToMany';"
47 DBICTest::Schema::Foo${suffix};
48 use base 'DBIx::Class::Core';
49 __PACKAGE__->table('foo');
50 __PACKAGE__->add_columns(
52 data_type => 'integer',
53 is_auto_increment => 1,
56 __PACKAGE__->set_primary_key('fooid');
59 __PACKAGE__->has_many('foo_to_bar' => 'DBICTest::Schema::FooToBar${suffix}' => 'bar');
60 __PACKAGE__->many_to_many( foos => foo_to_bar => 'bar' );
64 DBICTest::Schema::FooToBar${suffix};
66 use base 'DBIx::Class::Core';
67 __PACKAGE__->table('foo_to_bar');
68 __PACKAGE__->add_columns(
70 data_type => 'integer',
73 data_type => 'integer',
76 __PACKAGE__->belongs_to('foo' => 'DBICTest::Schema::Foo${suffix}');
77 __PACKAGE__->belongs_to('bar' => 'DBICTest::Schema::Foo${suffix}');
81 DBICTest::Schema::Bar${suffix};
83 use base 'DBIx::Class::Core';
84 __PACKAGE__->table('bar');
85 __PACKAGE__->add_columns(
87 data_type => 'integer',
88 is_auto_increment => 1,
93 __PACKAGE__->set_primary_key('barid');
94 __PACKAGE__->has_many('foo_to_bar' => 'DBICTest::Schema::FooToBar${suffix}' => 'foo');
96 __PACKAGE__->many_to_many( bars => foo_to_bar => 'foo' );