Merge branch '104-path_empty_brackets' of https://github.com/grim8634/catalyst-runtim...
[catagits/Catalyst-Runtime.git] / t / aggregate / unit_core_component_loading.t
index 2586f2d..a408dd7 100644 (file)
@@ -2,7 +2,7 @@
 # (do not forget to update the number of components in test 3 as well)
 # 5 extra tests for the loading options
 # One test for components in inner packages
-use Test::More tests => 2 + 6 * 24 + 8 + 1;
+use Test::More tests => 2 + 6 * 24 + 9 + 1;
 
 use strict;
 use warnings;
@@ -11,6 +11,7 @@ use File::Spec;
 use File::Path;
 
 my $libdir = 'test_trash';
+local @INC = @INC;
 unshift(@INC, $libdir);
 
 my $appclass = 'TestComponents';
@@ -54,7 +55,7 @@ sub write_component_file {
 }
 
 sub make_component_file {
-    my ($type, $prefix, $name) = @_;
+    my ($libdir, $appclass, $type, $prefix, $name) = @_;
 
     my $compbase = "Catalyst::${type}";
     my $fullname = "${appclass}::${prefix}::${name}";
@@ -78,9 +79,13 @@ EOF
 }
 
 foreach my $component (@components) {
-    make_component_file($component->{type},
-                        $component->{prefix},
-                        $component->{name});
+    make_component_file(
+        $libdir,
+        $appclass,
+        $component->{type},
+        $component->{prefix},
+        $component->{name},
+    );
 }
 
 my $shut_up_deprecated_warnings = q{
@@ -138,17 +143,29 @@ $appclass = 'ExtraOptions';
 push @components, { type => 'View', prefix => 'Extra', name => 'Foo' };
 
 foreach my $component (@components) {
-    make_component_file($component->{type},
-                        $component->{prefix},
-                        $component->{name});
+    make_component_file(
+        $libdir,
+        $appclass,
+        $component->{type},
+        $component->{prefix},
+        $component->{name},
+    );
 }
 
+    make_component_file(
+        $libdir,
+        'ExternalExtra',
+        'Controller',
+        'Controller',
+        'FooExternal',
+    );
+
 eval qq(
 package $appclass;
 use Catalyst;
 $shut_up_deprecated_warnings
 __PACKAGE__->config->{ setup_components } = {
-    search_extra => [ '::Extra' ],
+    search_extra => [ '::Extra', 'ExternalExtra::Controller' ],
     except       => [ "${appclass}::Controller::Foo" ]
 };
 __PACKAGE__->setup;
@@ -158,11 +175,13 @@ can_ok( $appclass, 'components');
 
 $complist = $appclass->components;
 
-is(scalar keys %$complist, 24+1, "Correct number of components loaded");
+is(scalar keys %$complist, 24+2, "Correct number of components loaded");
 
 ok( !exists $complist->{ "${appclass}::Controller::Foo" }, 'Controller::Foo was skipped' );
 ok( exists $complist->{ "${appclass}::Extra::Foo" }, 'Extra::Foo was loaded' );
 
+isa_ok($appclass->controller('FooExternal'), 'Catalyst::Controller', 'ExternalExtra::Controller::FooExternal was loaded');
+
 rmtree($libdir);
 
 $appclass = "ComponentOnce";