From: André Walker Date: Fri, 20 Jul 2012 04:29:37 +0000 (-0300) Subject: added a warning to ->components(), and changed tests which called it to be after... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=ff942beb0bff49b955364171d35961fa1b5aae93 added a warning to ->components(), and changed tests which called it to be after setup_log --- diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index f9ebe51..46fc522 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -1458,12 +1458,18 @@ Returns a hash of components. sub components { my ( $class, $comps ) = @_; + # FIXME + # this is very wrong # people create components calling this sub directly, before setup + # also, $class->log doesn't work before setup_log $class->setup_config unless $class->container; my $container = $class->container; if ( $comps ) { + $class->log->warn(q{You are adding components using Catalyst's components method.}); + $class->log->warn(q{This behaviour is deprecated, please read}); + $class->log->warn(q{Catalyst::IOC::Container's documentation for better ways to do that.}); $container->add_component( $_ ) for keys %$comps; } diff --git a/t/aggregate/unit_core_component_setup_components.t b/t/aggregate/unit_core_component_setup_components.t index ffbbb99..fd40127 100644 --- a/t/aggregate/unit_core_component_setup_components.t +++ b/t/aggregate/unit_core_component_setup_components.t @@ -10,14 +10,14 @@ Moose::Meta::Class->create( TestAppComponents => ( }, )); -TestAppComponents->components( {} ); - # this is so TestAppComponents->container will work TestAppComponents->setup_config; # this is so TestAppComponents->log->warn will work TestAppComponents->setup_log; +TestAppComponents->components( {} ); + my @comps = TestAppComponents->locate_components; for my $component (@comps) { diff --git a/t/aggregate/unit_core_mvc.t b/t/aggregate/unit_core_mvc.t index 390c4c6..ea2d916 100644 --- a/t/aggregate/unit_core_mvc.t +++ b/t/aggregate/unit_core_mvc.t @@ -294,11 +294,11 @@ is( MyMVCTestAppDefaultModel->model , 'MyMVCTestAppDefaultModel::Model::M', 'def __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; + + __PACKAGE__->components( { map { ( ref($_)||$_ , $_ ) } + qw/MyApp::WithoutRegexFallback::Controller::Another::Foo/ } ); } {