1 BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
10 my $exp_warn = qr/The many-to-many relationship 'bars' is trying to create/;
14 local $SIG{__WARN__} = sub { $_[0] =~ $exp_warn ? push @w, $_[0] : warn $_[0] };
15 my $code = gen_code ( suffix => 1 );
17 local $ENV{DBIC_OVERWRITE_HELPER_METHODS_OK};
19 ok (! $@, 'Eval code without warnings suppression')
22 ok (@w, "Warning triggered without DBIC_OVERWRITE_HELPER_METHODS_OK");
27 local $SIG{__WARN__} = sub { $_[0] =~ $exp_warn ? push @w, $_[0] : warn $_[0] };
29 my $code = gen_code ( suffix => 2 );
31 local $ENV{DBIC_OVERWRITE_HELPER_METHODS_OK} = 1;
33 ok (! $@, 'Eval code with warnings suppression')
36 ok (! @w, "No warning triggered with DBIC_OVERWRITE_HELPER_METHODS_OK");
42 my $suffix = $args->{suffix};
50 DBICTest::Schema::Foo${suffix};
51 use base 'DBIx::Class::Core';
53 __PACKAGE__->table('foo');
54 __PACKAGE__->add_columns(
56 data_type => 'integer',
57 is_auto_increment => 1,
60 __PACKAGE__->set_primary_key('fooid');
63 __PACKAGE__->has_many('foo_to_bar' => 'DBICTest::Schema::FooToBar${suffix}' => 'bar');
64 __PACKAGE__->many_to_many( foos => foo_to_bar => 'bar' );
68 DBICTest::Schema::FooToBar${suffix};
70 use base 'DBIx::Class::Core';
71 __PACKAGE__->table('foo_to_bar');
72 __PACKAGE__->add_columns(
74 data_type => 'integer',
77 data_type => 'integer',
80 __PACKAGE__->belongs_to('foo' => 'DBICTest::Schema::Foo${suffix}');
81 __PACKAGE__->belongs_to('bar' => 'DBICTest::Schema::Foo${suffix}');
85 DBICTest::Schema::Bar${suffix};
87 use base 'DBIx::Class::Core';
89 __PACKAGE__->table('bar');
90 __PACKAGE__->add_columns(
92 data_type => 'integer',
93 is_auto_increment => 1,
97 __PACKAGE__->set_primary_key('barid');
98 __PACKAGE__->has_many('foo_to_bar' => 'DBICTest::Schema::FooToBar${suffix}' => 'foo');
100 __PACKAGE__->many_to_many( bars => foo_to_bar => 'foo' );