8 my $exp_warn = qr/The many-to-many relationship 'bars' is trying to create/;
12 local $SIG{__WARN__} = sub { $_[0] =~ $exp_warn ? push @w, $_[0] : warn $_[0] };
13 my $code = gen_code ( suffix => 1 );
15 local $ENV{DBIC_OVERWRITE_HELPER_METHODS_OK};
17 ok (! $@, 'Eval code without warnings suppression')
20 ok (@w, "Warning triggered without DBIC_OVERWRITE_HELPER_METHODS_OK");
25 local $SIG{__WARN__} = sub { $_[0] =~ $exp_warn ? push @w, $_[0] : warn $_[0] };
27 my $code = gen_code ( suffix => 2 );
29 local $ENV{DBIC_OVERWRITE_HELPER_METHODS_OK} = 1;
31 ok (! $@, 'Eval code with warnings suppression')
34 ok (! @w, "No warning triggered with DBIC_OVERWRITE_HELPER_METHODS_OK");
40 my $suffix = $args->{suffix};
48 DBICTest::Schema::Foo${suffix};
49 use base 'DBIx::Class::Core';
51 __PACKAGE__->table('foo');
52 __PACKAGE__->add_columns(
54 data_type => 'integer',
55 is_auto_increment => 1,
58 __PACKAGE__->set_primary_key('fooid');
61 __PACKAGE__->has_many('foo_to_bar' => 'DBICTest::Schema::FooToBar${suffix}' => 'bar');
62 __PACKAGE__->many_to_many( foos => foo_to_bar => 'bar' );
66 DBICTest::Schema::FooToBar${suffix};
68 use base 'DBIx::Class::Core';
69 __PACKAGE__->table('foo_to_bar');
70 __PACKAGE__->add_columns(
72 data_type => 'integer',
75 data_type => 'integer',
78 __PACKAGE__->belongs_to('foo' => 'DBICTest::Schema::Foo${suffix}');
79 __PACKAGE__->belongs_to('bar' => 'DBICTest::Schema::Foo${suffix}');
83 DBICTest::Schema::Bar${suffix};
85 use base 'DBIx::Class::Core';
87 __PACKAGE__->table('bar');
88 __PACKAGE__->add_columns(
90 data_type => 'integer',
91 is_auto_increment => 1,
95 __PACKAGE__->set_primary_key('barid');
96 __PACKAGE__->has_many('foo_to_bar' => 'DBICTest::Schema::FooToBar${suffix}' => 'foo');
98 __PACKAGE__->many_to_many( bars => foo_to_bar => 'foo' );