Fix UTF8Column out of order loading warning
[dbsrgits/DBIx-Class.git] / t / 85utf8.t
index 9f1ab0f..5ea1a60 100644 (file)
@@ -6,22 +6,52 @@ use Test::Warn;
 use lib qw(t/lib);
 use DBICTest;
 
-warning_like (
-  sub {
-    package A::Comp;
-    use base 'DBIx::Class';
-    sub store_column { shift->next::method (@_) };
-    1;
+{
+  package A::Comp;
+  use base 'DBIx::Class';
+  sub store_column { shift->next::method (@_) };
+  1;
+}
+
+{
+  package A::SubComp;
+  use base 'A::Comp';
+  1;
+}
 
+warnings_like (
+  sub {
     package A::Test;
     use base 'DBIx::Class::Core';
-    __PACKAGE__->load_components(qw(UTF8Columns +A::Comp));
+    __PACKAGE__->load_components(qw(UTF8Columns +A::SubComp +A::Comp));
     1;
   },
-  qr/Incorrect loading order of DBIx::Class::UTF8Columns.+affect other components overriding store_column \(A::Comp\)/,
+  [qr/Incorrect loading order of DBIx::Class::UTF8Columns.+affect other components overriding store_column \(A::Comp\)/],
   'incorrect order warning issued',
 );
 
+warnings_are (
+  sub {
+    package A::Test2;
+    use base 'DBIx::Class::Core';
+    __PACKAGE__->load_components(qw(Core +A::Comp Ordered UTF8Columns));
+    __PACKAGE__->load_components(qw(Ordered +A::Comp Row UTF8Columns Core));
+    1;
+  },
+  [],
+  'no spurious warnings issued',
+);
+
+my $test2_mro;
+my $idx = 0;
+for (@{mro::get_linear_isa ('A::Test2')} ) {
+  $test2_mro->{$_} = $idx++;
+}
+
+cmp_ok ($test2_mro->{'A::Comp'}, '<', $test2_mro->{'DBIx::Class::UTF8Columns'}, 'mro of Test2 correct (A::Comp before UTF8Col)' );
+cmp_ok ($test2_mro->{'DBIx::Class::UTF8Columns'}, '<', $test2_mro->{'DBIx::Class::Core'}, 'mro of Test2 correct (UTF8Col before Core)' );
+cmp_ok ($test2_mro->{'DBIx::Class::Core'}, '<', $test2_mro->{'DBIx::Class::Row'}, 'mro of Test2 correct (Core before Row)' );
+
 my $schema = DBICTest->init_schema();
 DBICTest::Schema::CD->load_components('UTF8Columns');
 DBICTest::Schema::CD->utf8_columns('title');