9 my $exp_warn = qr/The many-to-many relationship 'bars' is trying to create/;
13 local $SIG{__WARN__} = sub { $_[0] =~ $exp_warn ? push @w, $_[0] : warn $_[0] };
14 my $code = gen_code ( suffix => 1 );
16 ok (! $@, 'Eval code without warnings suppression')
19 ok (@w, "Warning triggered without DBIC_OVERWRITE_HELPER_METHODS_OK");
24 local $SIG{__WARN__} = sub { $_[0] =~ $exp_warn ? push @w, $_[0] : warn $_[0] };
26 my $code = gen_code ( suffix => 2 );
28 local $ENV{DBIC_OVERWRITE_HELPER_METHODS_OK} = 1;
30 ok (! $@, 'Eval code with warnings suppression')
33 ok (! @w, "No warning triggered with DBIC_OVERWRITE_HELPER_METHODS_OK");
39 my $suffix = $args->{suffix};
47 DBICTest::Schema::Foo${suffix};
48 use base 'DBIx::Class::Core';
50 __PACKAGE__->table('foo');
51 __PACKAGE__->add_columns(
53 data_type => 'integer',
54 is_auto_increment => 1,
57 __PACKAGE__->set_primary_key('fooid');
60 __PACKAGE__->has_many('foo_to_bar' => 'DBICTest::Schema::FooToBar${suffix}' => 'bar');
61 __PACKAGE__->many_to_many( foos => foo_to_bar => 'bar' );
65 DBICTest::Schema::FooToBar${suffix};
67 use base 'DBIx::Class::Core';
68 __PACKAGE__->table('foo_to_bar');
69 __PACKAGE__->add_columns(
71 data_type => 'integer',
74 data_type => 'integer',
77 __PACKAGE__->belongs_to('foo' => 'DBICTest::Schema::Foo${suffix}');
78 __PACKAGE__->belongs_to('bar' => 'DBICTest::Schema::Foo${suffix}');
82 DBICTest::Schema::Bar${suffix};
84 use base 'DBIx::Class::Core';
86 __PACKAGE__->table('bar');
87 __PACKAGE__->add_columns(
89 data_type => 'integer',
90 is_auto_increment => 1,
94 __PACKAGE__->set_primary_key('barid');
95 __PACKAGE__->has_many('foo_to_bar' => 'DBICTest::Schema::FooToBar${suffix}' => 'foo');
97 __PACKAGE__->many_to_many( bars => foo_to_bar => 'foo' );