test for overriding apply_single_role_to_package
Graham Knop [Thu, 11 Jul 2013 00:40:11 +0000 (20:40 -0400)]
t/subclass.t [new file with mode: 0644]

diff --git a/t/subclass.t b/t/subclass.t
new file mode 100644 (file)
index 0000000..85cdacd
--- /dev/null
@@ -0,0 +1,40 @@
+use strict;
+use warnings FATAL => 'all';
+use Test::More;
+use Test::Fatal;
+
+my $backcompat_called;
+{
+  package RoleExtension;
+  use base 'Role::Tiny';
+
+  sub apply_single_role_to_package {
+    my $me = shift;
+    $me->SUPER::apply_single_role_to_package(@_);
+    $backcompat_called++;
+  }
+}
+
+{
+  package Role1;
+  $INC{'Role1.pm'} = __FILE__;
+  use Role::Tiny;
+  sub sub1 {}
+}
+
+{
+  package Role2;
+  $INC{'Role2.pm'} = __FILE__;
+  use Role::Tiny;
+  sub sub2 {}
+}
+
+{
+  package Class1;
+  RoleExtension->apply_roles_to_package(__PACKAGE__, 'Role1', 'Role2');
+}
+
+is $backcompat_called, 2,
+  'overridden apply_single_role_to_package called for backcompat';
+
+done_testing;