Introducing DBIx::Class::Schema::SanityChecker
[dbsrgits/DBIx-Class.git] / xt / extra / diagnostics / invalid_component_composition.t
1 BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
2
3 BEGIN { delete $ENV{DBIC_ASSERT_NO_FAILING_SANITY_CHECKS} }
4
5 use strict;
6 use warnings;
7
8 use Test::More;
9
10 use DBICTest::Util 'capture_stderr';
11 use DBICTest;
12
13
14 {
15   package DBICTest::Some::BaseResult;
16   use base "DBIx::Class::Core";
17
18   # order is important
19   __PACKAGE__->load_components(qw( FilterColumn InflateColumn::DateTime ));
20 }
21
22 {
23   package DBICTest::Some::Result;
24   use base "DBICTest::Some::BaseResult";
25
26   __PACKAGE__->table("sometable");
27
28   __PACKAGE__->add_columns(
29     somecolumn => { data_type => "datetime" },
30   );
31 }
32
33 {
34   package DBICTest::Some::Schema;
35   use base "DBIx::Class::Schema";
36   __PACKAGE__->schema_sanity_checker("DBIx::Class::Schema::SanityChecker");
37   __PACKAGE__->register_class( some_result => "DBICTest::Some::Result" );
38 }
39
40 like(
41   capture_stderr {
42     DBICTest::Some::Schema->connection(sub {} );
43   },
44   qr/Class 'DBICTest::Some::Result' was originally using the 'dfs' MRO affecting .+ register_column\(\)/,
45   'Proper incorrect composition warning emitted on StdErr'
46 );
47
48 done_testing;