removed component resolution regex fallback
[catagits/Catalyst-Runtime.git] / t / aggregate / unit_core_mvc.t
index 876d31a..7ef265d 100644 (file)
@@ -1,4 +1,4 @@
-use Test::More tests => 46;
+use Test::More;
 use strict;
 use warnings;
 
@@ -123,13 +123,13 @@ is ( MyMVCTestApp->model , 'MyMVCTestApp::Model::M', 'default_model in class met
         local *Catalyst::Log::warn = sub { $warnings++ };
 
         # object w/ regexp fallback
-        is_deeply( [ MyMVCTestApp->model( 'Test' ) ], [ MyMVCTestApp->components->{'MyMVCTestApp::Model::Test::Object'} ], 'Object returned' );
+        is_deeply( MyMVCTestApp->model( 'Test' ), undef, 'no regexp fallback' );
         ok( $warnings, 'regexp fallback warnings' );
     }
 
-    is_deeply( [ MyMVCTestApp->view('MyMVCTestApp::V::View$') ], [ 'MyMVCTestApp::V::View' ], 'Explicit return ok');
-    is_deeply( [ MyMVCTestApp->controller('MyMVCTestApp::C::Controller$') ], [ 'MyMVCTestApp::C::Controller' ], 'Explicit return ok');
-    is_deeply( [ MyMVCTestApp->model('MyMVCTestApp::M::Model$') ], [ 'MyMVCTestApp::M::Model' ], 'Explicit return ok');
+    is( MyMVCTestApp->view('MyMVCTestApp::V::View$'), undef, 'no regexp fallback');
+    is( MyMVCTestApp->controller('MyMVCTestApp::C::Controller$'), undef, 'no regexp fallback');
+    is( MyMVCTestApp->model('MyMVCTestApp::M::Model$'), undef, 'no regexp fallback');
 }
 
 {
@@ -175,9 +175,35 @@ is ( MyMVCTestApp->model , 'MyMVCTestApp::Model::M', 'default_model in class met
     my $x = $c->view('V', qw/foo2 bar2/);
     is_deeply($args, [qw/foo2 bar2/], '$c->view args passed to ACCEPT_CONTEXT ok');
 
-    # regexp fallback
-    $c->view('::View::V', qw/foo3 bar3/);
-    is_deeply($args, [qw/foo3 bar3/], 'args passed to ACCEPT_CONTEXT ok');
+}
+
+{
+    package MyApp::WithoutRegexFallback;
+
+    use base qw/Catalyst/;
 
+    __PACKAGE__->config( { disable_component_resolution_regex_fallback => 1 } );
 
+    __PACKAGE__->components( { map { ( ref($_)||$_ , $_ ) }
+        qw/MyApp::WithoutRegexFallback::Controller::Another::Foo/ } );
+
+    # allow $c->log->warn to work
+    __PACKAGE__->setup_log;
 }
+
+{
+    # test if non-regex component retrieval still works
+    is( MyApp::WithoutRegexFallback->controller('Another::Foo'),
+        'MyApp::WithoutRegexFallback::Controller::Another::Foo', 'controller Another::Foo found');
+}
+
+{
+    my $warnings = 0;
+    no warnings 'redefine';
+    local *Catalyst::Log::warn = sub { $warnings++ };
+
+    # try to get nonexisting object w/o regexp fallback
+    is( MyApp::WithoutRegexFallback->controller('Foo'), undef, 'no controller Foo found');
+}
+
+done_testing;