Merge 'trunk' into 'aggregate_more'
Tomas Doran [Thu, 12 Nov 2009 01:19:45 +0000 (01:19 +0000)]
r11487@t0mlaptop (orig r11457):  t0m | 2009-10-05 22:59:47 +0100
 r11483@t0mlaptop (orig r11453):  abraxxa | 2009-10-05 12:57:34 +0100
 Improved the suggested fix warning when component resolution uses regex fallback for fully qualified component names.
 Added disable_component_resolution_regex_fallback config option to switch off regex fallback for component resolution.

r11488@t0mlaptop (orig r11458):  t0m | 2009-10-05 22:59:52 +0100
 r11486@t0mlaptop (orig r11456):  t0m | 2009-10-05 22:59:01 +0100
 Tidy up changelog/attribution

r11503@t0mlaptop (orig r11468):  ilmari | 2009-10-06 16:30:41 +0100
Set ->request on the response object i Catalyst::Test::local_request--This line, and those below, will be ignored--

M    t/unit_load_catalyst_test.t
M    lib/Catalyst/Test.pm
M    Changes

r11519@t0mlaptop (orig r11484):  phaylon | 2009-10-07 18:21:47 +0100
added stub config section (incl TODO) to Cat.pm for things like 'current_view'
r11548@t0mlaptop (orig r11513):  caelum | 2009-10-12 17:18:22 +0100
fix uninitialized warning in ACL
r11549@t0mlaptop (orig r11514):  caelum | 2009-10-12 17:22:08 +0100
better fix for uninitialized warning
r11550@t0mlaptop (orig r11515):  t0m | 2009-10-12 18:10:32 +0100
Less cargo cult madness
r11554@t0mlaptop (orig r11519):  caelum | 2009-10-13 15:37:02 +0100
more correct fix for uninitialized warning from ACL
r11556@t0mlaptop (orig r11521):  dhoss | 2009-10-14 01:14:42 +0100
Snow Leopard uses COPYFILE_DISABLE
r11557@t0mlaptop (orig r11522):  dhoss | 2009-10-14 01:20:06 +0100
fixed regex for next mac codename/version, will have to actually figure out what the 10.7 codename is when it arrives
r11558@t0mlaptop (orig r11523):  dhoss | 2009-10-14 01:23:45 +0100
Attempted to make the error message more obvious
r11561@t0mlaptop (orig r11526):  dhoss | 2009-10-14 01:50:26 +0100
fixed error message for mac osx 10.7
r11568@t0mlaptop (orig r11533):  hobbs | 2009-10-15 03:32:28 +0100
Give people a pointer to chase if they're looking for info on $c->req->user

r11574@t0mlaptop (orig r11539):  t0m | 2009-10-15 22:19:26 +0100
Add docs I promised for  r11484
r11622@t0mlaptop (orig r11587):  jshirley | 2009-10-16 21:06:19 +0100
The longawaited nginx patch to support non-root apps, and some pod
r11623@t0mlaptop (orig r11588):  jshirley | 2009-10-16 21:07:29 +0100
Changes for nginx patches
r11624@t0mlaptop (orig r11589):  jshirley | 2009-10-16 21:08:55 +0100
My favorite color is clear and I like to eat rocks
r11670@t0mlaptop (orig r11635):  t0m | 2009-10-19 18:02:59 +0100
Remove warnings from duplicate action declerations
r11675@t0mlaptop (orig r11640):  poisonbit | 2009-10-20 21:12:46 +0100
Example added to #Actions_in_your_application_class

r11676@t0mlaptop (orig r11641):  poisonbit | 2009-10-20 21:32:41 +0100
Formating (a lost space and line break)

r11677@t0mlaptop (orig r11642):  poisonbit | 2009-10-20 21:34:45 +0100
More regresion from 11640, correcting parentheses and endpoint.

r11678@t0mlaptop (orig r11643):  poisonbit | 2009-10-20 22:08:47 +0100
Change in actions inside roles.
http://bobtfish.livejournal.com/264317.html

r11679@t0mlaptop (orig r11644):  poisonbit | 2009-10-20 23:16:03 +0100
Fixes to pass podchecker OK

r11714@t0mlaptop (orig r11679):  rafl | 2009-10-28 23:54:56 +0000
Enable Catalyst::Utils::home() to find home within Dist::Zilla built dists.

Courtesy of nperez.
r11716@t0mlaptop (orig r11681):  t0m | 2009-10-29 00:43:07 +0000
Make URI a link to make it super obvious
r11796@t0mlaptop (orig r11761):  t0m | 2009-11-05 00:11:15 +0000
Need newer LWP for tests to pass as suggested on list by Jose Luis Martinez
r11811@t0mlaptop (orig r11776):  altreus | 2009-11-06 17:09:51 +0000
Add doc for no-args call to ->uri_for
r11813@t0mlaptop (orig r11778):  dhoss | 2009-11-06 17:13:27 +0000
fixed options passed to devel server so that author tests pass
r11814@t0mlaptop (orig r11779):  altreus | 2009-11-06 17:14:49 +0000
Amend doc to not mention using undef in ->uri_for
r11816@t0mlaptop (orig r11781):  t0m | 2009-11-07 16:50:59 +0000
Back out change from -port to -l - svn merge -r 11778:11777
r11823@t0mlaptop (orig r11788):  rafl | 2009-11-09 22:21:19 +0000
Make request->body fail when used as a writer.
r11824@t0mlaptop (orig r11789):  t0m | 2009-11-10 19:51:33 +0000
Fix changelog, me--
r11825@t0mlaptop (orig r11790):  t0m | 2009-11-10 19:56:09 +0000
Warn on case_sensitive being set, remove documentation
r11827@t0mlaptop (orig r11792):  t0m | 2009-11-10 21:36:06 +0000
Return 1, only currently works by chance
r11828@t0mlaptop (orig r11793):  t0m | 2009-11-10 21:37:26 +0000
Also retarded
r11829@t0mlaptop (orig r11794):  t0m | 2009-11-10 21:41:27 +0000
And lets not change behaviour with the log flush change..
r11836@t0mlaptop (orig r11801):  t0m | 2009-11-12 01:12:05 +0000
Bring the changelog up to date.

36 files changed:
t/aggregate/c3_appclass_bug.t [moved from t/c3_appclass_bug.t with 100% similarity]
t/aggregate/c3_mro.t [moved from t/c3_mro.t with 98% similarity]
t/aggregate/caf_backcompat.t [moved from t/caf_backcompat.t with 100% similarity]
t/aggregate/custom_live_component_controller_action_auto_doublebug.t [moved from t/custom_live_component_controller_action_auto_doublebug.t with 95% similarity]
t/aggregate/custom_live_path_bug.t [moved from t/custom_live_path_bug.t with 94% similarity]
t/aggregate/meta_method_unneeded.t [moved from t/meta_method_unneeded.t with 95% similarity]
t/aggregate/unit_controller_actions.t [moved from t/unit_controller_actions.t with 100% similarity]
t/aggregate/unit_controller_config.t [moved from t/unit_controller_config.t with 100% similarity]
t/aggregate/unit_controller_namespace.t [moved from t/unit_controller_namespace.t with 100% similarity]
t/aggregate/unit_core_action.t [moved from t/unit_core_action.t with 100% similarity]
t/aggregate/unit_core_classdata.t [moved from t/unit_core_classdata.t with 100% similarity]
t/aggregate/unit_core_component.t [moved from t/unit_core_component.t with 99% similarity]
t/aggregate/unit_core_component_loading.t [moved from t/unit_core_component_loading.t with 94% similarity]
t/aggregate/unit_core_component_mro.t [moved from t/unit_core_component_mro.t with 81% similarity]
t/aggregate/unit_core_engine_fixenv-iis6.t [moved from t/unit_core_engine_fixenv-iis6.t with 100% similarity]
t/aggregate/unit_core_engine_fixenv-lighttpd.t [moved from t/unit_core_engine_fixenv-lighttpd.t with 100% similarity]
t/aggregate/unit_core_log.t [moved from t/unit_core_log.t with 91% similarity]
t/aggregate/unit_core_merge_config_hashes.t [moved from t/unit_core_merge_config_hashes.t with 84% similarity]
t/aggregate/unit_core_mvc.t [new file with mode: 0644]
t/aggregate/unit_core_path_to.t [moved from t/unit_core_path_to.t with 100% similarity]
t/aggregate/unit_core_plugin.t [moved from t/unit_core_plugin.t with 94% similarity]
t/aggregate/unit_core_setup.t [moved from t/unit_core_setup.t with 100% similarity]
t/aggregate/unit_core_setup_log.t [moved from t/unit_core_setup_log.t with 100% similarity]
t/aggregate/unit_core_setup_stats.t [moved from t/unit_core_setup_stats.t with 77% similarity]
t/aggregate/unit_core_uri_for.t [moved from t/unit_core_uri_for.t with 99% similarity]
t/aggregate/unit_core_uri_with.t [moved from t/unit_core_uri_with.t with 100% similarity]
t/aggregate/unit_dispatcher_requestargs_restore.t [moved from t/unit_dispatcher_requestargs_restore.t with 91% similarity]
t/aggregate/unit_load_catalyst_test.t [moved from t/unit_load_catalyst_test.t with 95% similarity]
t/aggregate/unit_metaclass_compat_extend_non_moose_controller.t [moved from t/unit_metaclass_compat_extend_non_moose_controller.t with 100% similarity]
t/aggregate/unit_metaclass_compat_non_moose.t [moved from t/unit_metaclass_compat_non_moose.t with 100% similarity]
t/aggregate/unit_metaclass_compat_non_moose_controller.t [moved from t/unit_metaclass_compat_non_moose_controller.t with 93% similarity]
t/aggregate/unit_response.t [moved from t/unit_response.t with 100% similarity]
t/aggregate/unit_utils_env_value.t [moved from t/unit_utils_env_value.t with 95% similarity]
t/aggregate/unit_utils_prefix.t [moved from t/unit_utils_prefix.t with 93% similarity]
t/aggregate/unit_utils_request.t [moved from t/unit_utils_request.t with 90% similarity]
t/unit_core_mvc.t [deleted file]

similarity index 98%
rename from t/c3_mro.t
rename to t/aggregate/c3_mro.t
index d987544..99057c8 100644 (file)
@@ -15,7 +15,7 @@ my @cat_mods;
 
   local @INC = grep {/blib/} @INC;
   @cat_mods = (
-    'Catalyst', 
+    'Catalyst',
     Module::Pluggable::Object->new(search_path => ['Catalyst'])->plugins,
   );
 }
@@ -4,7 +4,7 @@ use strict;
 use warnings;
 
 use FindBin;
-use lib "$FindBin::Bin/lib";
+use lib "$FindBin::Bin/../lib";
 
 our $iters;
 
@@ -22,23 +22,23 @@ else {
         run_tests();
     }
 }
-    
+
 sub run_tests {
     SKIP:
     {
         if ( $ENV{CATALYST_SERVER} ) {
             skip 'Using remote server', 3;
         }
-        
+
         {
             my @expected = qw[
                 TestAppDoubleAutoBug::Controller::Root->auto
                 TestAppDoubleAutoBug::Controller::Root->default
                 TestAppDoubleAutoBug::Controller::Root->end
             ];
-    
+
             my $expected = join( ", ", @expected );
-    
+
             ok( my $response = request('http://localhost/action/auto/one'), 'auto + local' );
             is( $response->header('X-Catalyst-Executed'),
                 $expected, 'Executed actions' );
similarity index 94%
rename from t/custom_live_path_bug.t
rename to t/aggregate/custom_live_path_bug.t
index 9bbbd55..a6081c4 100644 (file)
@@ -4,7 +4,7 @@ use strict;
 use warnings;
 
 use FindBin;
-use lib "$FindBin::Bin/lib";
+use lib "$FindBin::Bin/../lib";
 
 our $iters;
 
@@ -22,14 +22,14 @@ else {
         run_tests();
     }
 }
-    
+
 sub run_tests {
     SKIP:
     {
         if ( $ENV{CATALYST_SERVER} ) {
             skip 'Using remote server', 2;
         }
-        
+
         {
             my $expected = 'This is the foo method.';
             ok( my $response = request('http://localhost/'), 'response ok' );
similarity index 95%
rename from t/meta_method_unneeded.t
rename to t/aggregate/meta_method_unneeded.t
index aa43472..f52a9b4 100644 (file)
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 use FindBin qw/$Bin/;
-use lib "$Bin/lib";
+use lib "$Bin/../lib";
 use Test::More tests => 1;
 use Test::Exception;
 use Carp ();
similarity index 99%
rename from t/unit_core_component.t
rename to t/aggregate/unit_core_component.t
index 53d6567..69ac6c0 100644 (file)
@@ -89,5 +89,5 @@ is_deeply([ MyApp->comp('Foo') ], \@complist, 'Fallthrough return ok');
 
     $c->component('Mode', qw/foo3 bar3/);
     is_deeply($args, [qw/foo3 bar3/], 'args passed to ACCEPT_CONTEXT ok');
-} 
+}
 
similarity index 94%
rename from t/unit_core_component_loading.t
rename to t/aggregate/unit_core_component_loading.t
index 1944ab6..2c53144 100644 (file)
@@ -11,6 +11,7 @@ use File::Spec;
 use File::Path;
 
 my $libdir = 'test_trash';
+local @INC = @INC;
 unshift(@INC, $libdir);
 
 my $appclass = 'TestComponents';
@@ -41,7 +42,7 @@ my @components = (
     { type => 'View', prefix => 'View', name => 'Foo' },
 );
 
-sub write_component_file { 
+sub write_component_file {
   my ($dir_list, $module_name, $content) = @_;
 
   my $dir  = File::Spec->catdir(@$dir_list);
@@ -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,9 +143,13 @@ $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},
+    );
 }
 
 eval qq(
@@ -171,7 +180,7 @@ write_component_file([$libdir, $appclass, 'Model'], 'TopLevel', <<EOF);
 package ${appclass}::Model::TopLevel;
 use base 'Catalyst::Model';
 sub COMPONENT {
+
     my \$self = shift->next::method(\@_);
     no strict 'refs';
     *{\__PACKAGE__ . "::whoami"} = sub { return \__PACKAGE__; };
similarity index 81%
rename from t/unit_core_component_mro.t
rename to t/aggregate/unit_core_component_mro.t
index a8699c3..8e9a064 100644 (file)
@@ -17,13 +17,13 @@ use warnings;
 }
 
 my $warn = '';
-{  
+{
   local $SIG{__WARN__} = sub {
-    $warn .= $_[0];  
+    $warn .= $_[0];
   };
   MyApp::MyComponent->COMPONENT('MyApp');
 }
 
-like($warn, qr/after Catalyst::Component in MyApp::Component/, 
+like($warn, qr/after Catalyst::Component in MyApp::Component/,
     'correct warning thrown');
 
similarity index 91%
rename from t/unit_core_log.t
rename to t/aggregate/unit_core_log.t
index 26a52d3..f488d48 100644 (file)
@@ -1,17 +1,12 @@
 use strict;
 use warnings;
 
-use Test::More tests => 23;
+use Test::More tests => 22;
 
-my $LOG;
+use Catalyst::Log;
 
-BEGIN {
-    chdir 't' if -d 't';
-    use lib '../lib';
-    $LOG = 'Catalyst::Log';
-    use_ok $LOG or die;
-}
-my @MESSAGES;
+local *Catalyst::Log::_send_to_log;
+local our @MESSAGES;
 {
     no warnings 'redefine';
     *Catalyst::Log::_send_to_log = sub {
@@ -20,6 +15,8 @@ my @MESSAGES;
     };
 }
 
+my $LOG = 'Catalyst::Log';
+
 can_ok $LOG, 'new';
 ok my $log = $LOG->new, '... and creating a new log object should succeed';
 isa_ok $log, $LOG, '... and the object it returns';
similarity index 84%
rename from t/unit_core_merge_config_hashes.t
rename to t/aggregate/unit_core_merge_config_hashes.t
index 53f8be2..1ac737b 100644 (file)
@@ -34,10 +34,10 @@ my @tests = (
     },
 );
 
-plan tests => scalar @tests + 1;
+plan tests => scalar @tests;
 
-use_ok('Catalyst');
+use Catalyst::Component;
 
 for my $test ( @ tests ) {
-    is_deeply( Catalyst->merge_config_hashes( @{ $test->{ given } } ), $test->{ expects } );
+    is_deeply( Catalyst::Component->merge_config_hashes( @{ $test->{ given } } ), $test->{ expects } );
 }
diff --git a/t/aggregate/unit_core_mvc.t b/t/aggregate/unit_core_mvc.t
new file mode 100644 (file)
index 0000000..876d31a
--- /dev/null
@@ -0,0 +1,183 @@
+use Test::More tests => 46;
+use strict;
+use warnings;
+
+use_ok('Catalyst');
+
+my @complist =
+  map { "MyMVCTestApp::$_"; }
+  qw/C::Controller M::Model V::View Controller::C Model::M View::V Controller::Model::Dummy::Model Model::Dummy::Model/;
+
+{
+
+    package MyMVCTestApp;
+
+    use base qw/Catalyst/;
+
+    __PACKAGE__->components( { map { ( ref($_)||$_ , $_ ) } @complist } );
+
+    my $thingie={};
+    bless $thingie, 'Some::Test::Object';
+    __PACKAGE__->components->{'MyMVCTestApp::Model::Test::Object'} = $thingie;
+
+    # allow $c->log->warn to work
+    __PACKAGE__->setup_log;
+}
+
+is( MyMVCTestApp->view('View'), 'MyMVCTestApp::V::View', 'V::View ok' );
+
+is( MyMVCTestApp->controller('Controller'),
+    'MyMVCTestApp::C::Controller', 'C::Controller ok' );
+
+is( MyMVCTestApp->model('Model'), 'MyMVCTestApp::M::Model', 'M::Model ok' );
+
+is( MyMVCTestApp->model('Dummy::Model'), 'MyMVCTestApp::Model::Dummy::Model', 'Model::Dummy::Model ok' );
+
+isa_ok( MyMVCTestApp->model('Test::Object'), 'Some::Test::Object', 'Test::Object ok' );
+
+is( MyMVCTestApp->controller('Model::Dummy::Model'), 'MyMVCTestApp::Controller::Model::Dummy::Model', 'Controller::Model::Dummy::Model ok' );
+
+is( MyMVCTestApp->view('V'), 'MyMVCTestApp::View::V', 'View::V ok' );
+
+is( MyMVCTestApp->controller('C'), 'MyMVCTestApp::Controller::C', 'Controller::C ok' );
+
+is( MyMVCTestApp->model('M'), 'MyMVCTestApp::Model::M', 'Model::M ok' );
+
+# failed search
+{
+    is( MyMVCTestApp->model('DNE'), undef, 'undef for invalid search' );
+}
+
+is_deeply( [ sort MyMVCTestApp->views ],
+           [ qw/V View/ ],
+           'views ok' );
+
+is_deeply( [ sort MyMVCTestApp->controllers ],
+           [ qw/C Controller Model::Dummy::Model/ ],
+           'controllers ok');
+
+is_deeply( [ sort MyMVCTestApp->models ],
+           [ qw/Dummy::Model M Model Test::Object/ ],
+           'models ok');
+
+{
+    my $warnings = 0;
+    no warnings 'redefine';
+    local *Catalyst::Log::warn = sub { $warnings++ };
+
+    like (MyMVCTestApp->view , qr/^MyMVCTestApp\::(V|View)\::/ , 'view() with no defaults returns *something*');
+    ok( $warnings, 'view() w/o a default is random, warnings thrown' );
+}
+
+is ( bless ({stash=>{current_view=>'V'}}, 'MyMVCTestApp')->view , 'MyMVCTestApp::View::V', 'current_view ok');
+
+my $view = bless {} , 'MyMVCTestApp::View::V';
+is ( bless ({stash=>{current_view_instance=> $view }}, 'MyMVCTestApp')->view , $view, 'current_view_instance ok');
+
+is ( bless ({stash=>{current_view_instance=> $view, current_view=>'MyMVCTestApp::V::View' }}, 'MyMVCTestApp')->view , $view,
+  'current_view_instance precedes current_view ok');
+
+{
+    my $warnings = 0;
+    no warnings 'redefine';
+    local *Catalyst::Log::warn = sub { $warnings++ };
+
+    ok( my $model = MyMVCTestApp->model );
+
+    ok( (($model =~ /^MyMVCTestApp\::(M|Model)\::/) ||
+        $model->isa('Some::Test::Object')),
+        'model() with no defaults returns *something*' );
+
+    ok( $warnings, 'model() w/o a default is random, warnings thrown' );
+}
+
+is ( bless ({stash=>{current_model=>'M'}}, 'MyMVCTestApp')->model , 'MyMVCTestApp::Model::M', 'current_model ok');
+
+my $model = bless {} , 'MyMVCTestApp::Model::M';
+is ( bless ({stash=>{current_model_instance=> $model }}, 'MyMVCTestApp')->model , $model, 'current_model_instance ok');
+
+is ( bless ({stash=>{current_model_instance=> $model, current_model=>'MyMVCTestApp::M::Model' }}, 'MyMVCTestApp')->model , $model,
+  'current_model_instance precedes current_model ok');
+
+MyMVCTestApp->config->{default_view} = 'V';
+is ( bless ({stash=>{}}, 'MyMVCTestApp')->view , 'MyMVCTestApp::View::V', 'default_view ok');
+is ( MyMVCTestApp->view , 'MyMVCTestApp::View::V', 'default_view in class method ok');
+
+MyMVCTestApp->config->{default_model} = 'M';
+is ( bless ({stash=>{}}, 'MyMVCTestApp')->model , 'MyMVCTestApp::Model::M', 'default_model ok');
+is ( MyMVCTestApp->model , 'MyMVCTestApp::Model::M', 'default_model in class method ok');
+
+# regexp behavior tests
+{
+    # is_deeply is used because regexp behavior means list context
+    is_deeply( [ MyMVCTestApp->view( qr{^V[ie]+w$} ) ], [ 'MyMVCTestApp::V::View' ], 'regexp view ok' );
+    is_deeply( [ MyMVCTestApp->controller( qr{Dummy\::Model$} ) ], [ 'MyMVCTestApp::Controller::Model::Dummy::Model' ], 'regexp controller ok' );
+    is_deeply( [ MyMVCTestApp->model( qr{Dum{2}y} ) ], [ 'MyMVCTestApp::Model::Dummy::Model' ], 'regexp model ok' );
+
+    # object w/ qr{}
+    is_deeply( [ MyMVCTestApp->model( qr{Test} ) ], [ MyMVCTestApp->components->{'MyMVCTestApp::Model::Test::Object'} ], 'Object returned' );
+
+    {
+        my $warnings = 0;
+        no warnings 'redefine';
+        local *Catalyst::Log::warn = sub { $warnings++ };
+
+        # object w/ regexp fallback
+        is_deeply( [ MyMVCTestApp->model( 'Test' ) ], [ MyMVCTestApp->components->{'MyMVCTestApp::Model::Test::Object'} ], 'Object returned' );
+        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');
+}
+
+{
+    my @expected = qw( MyMVCTestApp::C::Controller MyMVCTestApp::Controller::C );
+    is_deeply( [ sort MyMVCTestApp->controller( qr{^C} ) ], \@expected, 'multiple controller returns from regexp search' );
+}
+
+{
+    my @expected = qw( MyMVCTestApp::V::View MyMVCTestApp::View::V );
+    is_deeply( [ sort MyMVCTestApp->view( qr{^V} ) ], \@expected, 'multiple view returns from regexp search' );
+}
+
+{
+    my @expected = qw( MyMVCTestApp::M::Model MyMVCTestApp::Model::M );
+    is_deeply( [ sort MyMVCTestApp->model( qr{^M} ) ], \@expected, 'multiple model returns from regexp search' );
+}
+
+# failed search
+{
+    is( scalar MyMVCTestApp->controller( qr{DNE} ), 0, '0 results for failed search' );
+}
+
+#checking @args passed to ACCEPT_CONTEXT
+{
+    my $args;
+
+    {
+        no warnings 'once';
+        *MyMVCTestApp::Model::M::ACCEPT_CONTEXT = sub { my ($self, $c, @args) = @_; $args= \@args};
+        *MyMVCTestApp::View::V::ACCEPT_CONTEXT = sub { my ($self, $c, @args) = @_; $args= \@args};
+    }
+
+    my $c = bless {}, 'MyMVCTestApp';
+
+    # test accept-context with class rather than instance
+    MyMVCTestApp->model('M', qw/foo bar/);
+    is_deeply($args, [qw/foo bar/], 'MyMVCTestApp->model args passed to ACCEPT_CONTEXT ok');
+
+
+    $c->model('M', qw/foo bar/);
+    is_deeply($args, [qw/foo bar/], '$c->model args passed to ACCEPT_CONTEXT ok');
+
+    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');
+
+
+}
similarity index 94%
rename from t/unit_core_plugin.t
rename to t/aggregate/unit_core_plugin.t
index 03d16f6..11cef84 100644 (file)
@@ -11,9 +11,8 @@ use lib 't/lib';
 
     package Faux::Plugin;
 
-    sub new { bless {}, shift }
-    my $count = 1;
-    sub count { $count++ }
+    sub new { bless { count => 1 }, shift }
+    sub count { shift->{count}++ }
 }
 
 my $warnings = 0;
similarity index 77%
rename from t/unit_core_setup_stats.t
rename to t/aggregate/unit_core_setup_stats.t
index 11ef840..9aca059 100644 (file)
@@ -6,7 +6,7 @@ use Class::MOP::Class;
 
 use Catalyst ();
 
-my %log_messages; # TODO - Test log messages as expected.
+local our %log_messages; # TODO - Test log messages as expected.
 my $mock_log = Class::MOP::Class->create_anon_class(
     methods => {
         map { my $level = $_;
@@ -21,10 +21,11 @@ my $mock_log = Class::MOP::Class->create_anon_class(
 
 sub mock_app {
     my $name = shift;
+    my $mock_log = shift;
     %log_messages = (); # Flatten log messages.
     my $meta = Moose->init_meta( for_class => $name );
     $meta->superclasses('Catalyst');
-    $meta->add_method('log', sub { $mock_log }); 
+    $meta->add_method('log', sub { $mock_log });
     return $meta->name;
 }
 
@@ -36,17 +37,17 @@ foreach my $name (grep { /^(CATALYST|TESTAPP)/ } keys %ENV) {
 }
 
 {
-    my $app = mock_app('TestAppNoStats');
+    my $app = mock_app('TestAppNoStats', $mock_log);
     $app->setup_stats();
     ok !$app->use_stats, 'stats off by default';
 }
 {
-    my $app = mock_app('TestAppStats');
+    my $app = mock_app('TestAppStats', $mock_log);
     $app->setup_stats(1);
     ok $app->use_stats, 'stats on if you say >setup_stats(1)';
 }
 {
-    my $app = mock_app('TestAppStatsDebugTurnsStatsOn');
+    my $app = mock_app('TestAppStatsDebugTurnsStatsOn', $mock_log);
     $app->meta->add_method('debug' => sub { 1 });
     $app->setup_stats();
     ok $app->use_stats, 'debug on turns stats on';
@@ -54,14 +55,14 @@ foreach my $name (grep { /^(CATALYST|TESTAPP)/ } keys %ENV) {
 {
     local %ENV = %ENV;
     $ENV{CATALYST_STATS} = 1;
-    my $app = mock_app('TestAppStatsEnvSet');
+    my $app = mock_app('TestAppStatsEnvSet', $mock_log);
     $app->setup_stats();
     ok $app->use_stats, 'ENV turns stats on';
 }
 {
     local %ENV = %ENV;
     $ENV{CATALYST_STATS} = 0;
-    my $app = mock_app('TestAppStatsEnvUnset');
+    my $app = mock_app('TestAppStatsEnvUnset', $mock_log);
     $app->meta->add_method('debug' => sub { 1 });
     $app->setup_stats(1);
     ok !$app->use_stats, 'ENV turns stats off, even when debug on and ->setup_stats(1)';
similarity index 99%
rename from t/unit_core_uri_for.t
rename to t/aggregate/unit_core_uri_for.t
index 3dd3a69..170e91b 100644 (file)
@@ -46,7 +46,7 @@ is(
 is (Catalyst::uri_for( $context, '/bar/wibble?' )->as_string,
    'http://127.0.0.1/foo/bar/wibble%3F', 'Question Mark gets encoded'
 );
-   
+
 is( Catalyst::uri_for( $context, qw/bar wibble?/, 'with space' )->as_string,
     'http://127.0.0.1/foo/yada/bar/wibble%3F/with%20space', 'Space gets encoded'
 );
similarity index 91%
rename from t/unit_dispatcher_requestargs_restore.t
rename to t/aggregate/unit_dispatcher_requestargs_restore.t
index 1ffff9c..9c4b7fa 100644 (file)
@@ -1,6 +1,6 @@
 # Insane test case for the behavior needed by Plugin::Auhorization::ACL
 
-# We have to localise $c->request->{arguments} in 
+# We have to localise $c->request->{arguments} in
 # Catalyst::Dispatcher::_do_forward, rather than using save and restore,
 # as otherwise, the calling $c->detach on an action which says
 # die $Catalyst:DETACH causes the request arguments to not get restored,
@@ -14,7 +14,7 @@
 use strict;
 use warnings;
 use FindBin qw/$Bin/;
-use lib "$Bin/lib";
+use lib "$Bin/../lib";
 use Catalyst::Test 'ACLTestApp';
 use Test::More tests => 1;
 
similarity index 95%
rename from t/unit_load_catalyst_test.t
rename to t/aggregate/unit_load_catalyst_test.t
index 7688380..d3f30ee 100644 (file)
@@ -5,9 +5,9 @@ use warnings;
 
 use FindBin;
 use lib         "$FindBin::Bin/lib";
-use Test::More  tests => 61;
+use Test::More  tests => 59;
 use FindBin qw/$Bin/;
-use lib "$Bin/lib";
+use lib "$Bin/../lib";
 use Catalyst::Utils;
 use HTTP::Request::Common;
 use Test::Exception;
@@ -89,9 +89,6 @@ use_ok( $Class );
                                 "               Content recorded in response" );
         ok( $c->stash,          "               Stash accessible" );
         ok( $c->action,         "               Action object accessible" );
-        ok( $res->request,      "               Response has request object" );
-        lives_and { is( $res->request->uri, $Url) }
-                                "               Request object has correct url";
     } }
 }
 
@@ -2,7 +2,7 @@ use strict;
 use warnings;
 
 use FindBin;
-use lib "$FindBin::Bin/lib";
+use lib "$FindBin::Bin/../lib";
 
 use Test::More tests => 1;
 use Test::Exception;
similarity index 95%
rename from t/unit_utils_env_value.t
rename to t/aggregate/unit_utils_env_value.t
index 015b455..5dd92cf 100644 (file)
@@ -1,9 +1,9 @@
 use strict;
 use warnings;
 
-use Test::More tests => 5;
+use Test::More tests => 4;
 
-BEGIN { use_ok("Catalyst::Utils") }
+use Catalyst::Utils;
 
 ##############################################################################
 ### No env vars defined
similarity index 93%
rename from t/unit_utils_prefix.t
rename to t/aggregate/unit_utils_prefix.t
index a1b7efa..506fbc2 100644 (file)
@@ -3,11 +3,11 @@
 use strict;
 use warnings;
 
-use Test::More tests => 9;
+use Test::More tests => 8;
 
 use lib "t/lib";
 
-BEGIN { use_ok("Catalyst::Utils") };
+use Catalyst::Utils;
 
 is( Catalyst::Utils::class2prefix('MyApp::V::Foo::Bar'), 'foo/bar', 'class2prefix works with M/V/C' );
 
similarity index 90%
rename from t/unit_utils_request.t
rename to t/aggregate/unit_utils_request.t
index ce74d55..e02791b 100644 (file)
@@ -1,9 +1,9 @@
 use strict;
 use warnings;
 
-use Test::More tests => 5;
+use Test::More tests => 4;
 
-use_ok('Catalyst::Utils');
+use Catalyst::Utils;
 
 {
     my $url = "/dump";
diff --git a/t/unit_core_mvc.t b/t/unit_core_mvc.t
deleted file mode 100644 (file)
index b5bbd8b..0000000
+++ /dev/null
@@ -1,227 +0,0 @@
-use Test::More tests => 51;
-use strict;
-use warnings;
-
-use_ok('Catalyst');
-
-my @complist =
-  map { "MyApp::$_"; }
-  qw/C::Controller M::Model V::View Controller::C Model::M View::V Controller::Model::Dummy::Model Model::Dummy::Model/;
-
-{
-
-    package MyApp;
-
-    use base qw/Catalyst/;
-
-    __PACKAGE__->components( { map { ( ref($_)||$_ , $_ ) } @complist } );
-
-    my $thingie={};
-    bless $thingie, 'Some::Test::Object';
-    __PACKAGE__->components->{'MyApp::Model::Test::Object'} = $thingie;
-
-    # allow $c->log->warn to work
-    __PACKAGE__->setup_log;
-}
-
-is( MyApp->view('View'), 'MyApp::V::View', 'V::View ok' );
-
-is( MyApp->controller('Controller'),
-    'MyApp::C::Controller', 'C::Controller ok' );
-
-is( MyApp->model('Model'), 'MyApp::M::Model', 'M::Model ok' );
-
-is( MyApp->model('Dummy::Model'), 'MyApp::Model::Dummy::Model', 'Model::Dummy::Model ok' );
-
-isa_ok( MyApp->model('Test::Object'), 'Some::Test::Object', 'Test::Object ok' );
-
-is( MyApp->controller('Model::Dummy::Model'), 'MyApp::Controller::Model::Dummy::Model', 'Controller::Model::Dummy::Model ok' );
-
-is( MyApp->view('V'), 'MyApp::View::V', 'View::V ok' );
-
-is( MyApp->controller('C'), 'MyApp::Controller::C', 'Controller::C ok' );
-
-is( MyApp->model('M'), 'MyApp::Model::M', 'Model::M ok' );
-
-# failed search
-{
-    is( MyApp->model('DNE'), undef, 'undef for invalid search' );
-}
-
-is_deeply( [ sort MyApp->views ],
-           [ qw/V View/ ],
-           'views ok' );
-
-is_deeply( [ sort MyApp->controllers ],
-           [ qw/C Controller Model::Dummy::Model/ ],
-           'controllers ok');
-
-is_deeply( [ sort MyApp->models ],
-           [ qw/Dummy::Model M Model Test::Object/ ],
-           'models ok');
-
-{
-    my $warnings = 0;
-    no warnings 'redefine';
-    local *Catalyst::Log::warn = sub { $warnings++ };
-
-    like (MyApp->view , qr/^MyApp\::(V|View)\::/ , 'view() with no defaults returns *something*');
-    ok( $warnings, 'view() w/o a default is random, warnings thrown' );
-}
-
-is ( bless ({stash=>{current_view=>'V'}}, 'MyApp')->view , 'MyApp::View::V', 'current_view ok');
-
-my $view = bless {} , 'MyApp::View::V'; 
-is ( bless ({stash=>{current_view_instance=> $view }}, 'MyApp')->view , $view, 'current_view_instance ok');
-
-is ( bless ({stash=>{current_view_instance=> $view, current_view=>'MyApp::V::View' }}, 'MyApp')->view , $view, 
-  'current_view_instance precedes current_view ok');
-
-{
-    my $warnings = 0;
-    no warnings 'redefine';
-    local *Catalyst::Log::warn = sub { $warnings++ };
-
-    ok( my $model = MyApp->model );
-
-    ok( (($model =~ /^MyApp\::(M|Model)\::/) ||
-        $model->isa('Some::Test::Object')),
-        'model() with no defaults returns *something*' );
-
-    ok( $warnings, 'model() w/o a default is random, warnings thrown' );
-}
-
-is ( bless ({stash=>{current_model=>'M'}}, 'MyApp')->model , 'MyApp::Model::M', 'current_model ok');
-
-my $model = bless {} , 'MyApp::Model::M'; 
-is ( bless ({stash=>{current_model_instance=> $model }}, 'MyApp')->model , $model, 'current_model_instance ok');
-
-is ( bless ({stash=>{current_model_instance=> $model, current_model=>'MyApp::M::Model' }}, 'MyApp')->model , $model, 
-  'current_model_instance precedes current_model ok');
-
-MyApp->config->{default_view} = 'V';
-is ( bless ({stash=>{}}, 'MyApp')->view , 'MyApp::View::V', 'default_view ok');
-is ( MyApp->view , 'MyApp::View::V', 'default_view in class method ok');
-
-MyApp->config->{default_model} = 'M';
-is ( bless ({stash=>{}}, 'MyApp')->model , 'MyApp::Model::M', 'default_model ok');
-is ( MyApp->model , 'MyApp::Model::M', 'default_model in class method ok');
-
-# regexp behavior tests
-{
-    # is_deeply is used because regexp behavior means list context
-    is_deeply( [ MyApp->view( qr{^V[ie]+w$} ) ], [ 'MyApp::V::View' ], 'regexp view ok' );
-    is_deeply( [ MyApp->controller( qr{Dummy\::Model$} ) ], [ 'MyApp::Controller::Model::Dummy::Model' ], 'regexp controller ok' );
-    is_deeply( [ MyApp->model( qr{Dum{2}y} ) ], [ 'MyApp::Model::Dummy::Model' ], 'regexp model ok' );
-    
-    # object w/ qr{}
-    is_deeply( [ MyApp->model( qr{Test} ) ], [ MyApp->components->{'MyApp::Model::Test::Object'} ], 'Object returned' );
-
-    {
-        my $warnings = 0;
-        no warnings 'redefine';
-        local *Catalyst::Log::warn = sub { $warnings++ };
-
-        # object w/ regexp fallback
-        is_deeply( [ MyApp->model( 'Test' ) ], [ MyApp->components->{'MyApp::Model::Test::Object'} ], 'Object returned' );
-        ok( $warnings, 'regexp fallback warnings' );
-    }
-
-    is_deeply( [ MyApp->view('MyApp::V::View$') ], [ 'MyApp::V::View' ], 'Explicit return ok');
-    is_deeply( [ MyApp->controller('MyApp::C::Controller$') ], [ 'MyApp::C::Controller' ], 'Explicit return ok');
-    is_deeply( [ MyApp->model('MyApp::M::Model$') ], [ 'MyApp::M::Model' ], 'Explicit return ok');
-}
-
-{
-    my @expected = qw( MyApp::C::Controller MyApp::Controller::C );
-    is_deeply( [ sort MyApp->controller( qr{^C} ) ], \@expected, 'multiple controller returns from regexp search' );
-}
-
-{
-    my @expected = qw( MyApp::V::View MyApp::View::V );
-    is_deeply( [ sort MyApp->view( qr{^V} ) ], \@expected, 'multiple view returns from regexp search' );
-}
-
-{
-    my @expected = qw( MyApp::M::Model MyApp::Model::M );
-    is_deeply( [ sort MyApp->model( qr{^M} ) ], \@expected, 'multiple model returns from regexp search' );
-}
-
-# failed search
-{
-    is( scalar MyApp->controller( qr{DNE} ), 0, '0 results for failed search' );
-}
-
-#checking @args passed to ACCEPT_CONTEXT
-{
-    my $args;
-
-    {
-        no warnings 'once';
-        *MyApp::Model::M::ACCEPT_CONTEXT = sub { my ($self, $c, @args) = @_; $args= \@args};
-        *MyApp::View::V::ACCEPT_CONTEXT = sub { my ($self, $c, @args) = @_; $args= \@args};
-    }
-
-    my $c = bless {}, 'MyApp';
-
-    # test accept-context with class rather than instance
-    MyApp->model('M', qw/foo bar/);
-    is_deeply($args, [qw/foo bar/], 'MyApp->model args passed to ACCEPT_CONTEXT ok');
-
-
-    $c->model('M', qw/foo bar/);
-    is_deeply($args, [qw/foo bar/], '$c->model args passed to ACCEPT_CONTEXT ok');
-
-    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');
-
-
-}
-
-{
-    my $warn = '';
-    no warnings 'redefine';
-    local *Catalyst::Log::warn = sub { $warn .= $_[1] };
-
-    is_deeply (MyApp->controller('MyApp::Controller::C'),
-        MyApp->components->{'MyApp::Controller::C'},
-        'controller by fully qualified name ok');
-
-    # You probably meant $c->controller('C') instead of $c->controller({'MyApp::Controller::C'})
-    my ($suggested_comp_name, $orig_comp_name) = $warn =~ /You probably meant (.*) instead of (.*) /;
-    isnt($suggested_comp_name, $orig_comp_name, 'suggested fix in warning for fully qualified component names makes sense' );
-}
-
-{
-    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');
-    ok( !$warnings, 'no regexp fallback warnings' );
-}