From: Yousef H. Alhashemi Date: Wed, 26 Aug 2009 14:33:15 +0000 (+0000) Subject: More actions moved to root controllers. X-Git-Tag: 5.80013~12^2~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=9d04b6857491ce04e79cf93bdd45727e052ad6e6 More actions moved to root controllers. --- diff --git a/t/lib/PluginTestApp.pm b/t/lib/PluginTestApp.pm index c476736..1031586 100644 --- a/t/lib/PluginTestApp.pm +++ b/t/lib/PluginTestApp.pm @@ -6,48 +6,6 @@ use Catalyst qw( +TestApp::Plugin::FullyQualified ); -sub compile_time_plugins : Local { - my ( $self, $c ) = @_; - - isa_ok $c, 'Catalyst::Plugin::Test::Plugin'; - isa_ok $c, 'TestApp::Plugin::FullyQualified'; - - can_ok $c, 'registered_plugins'; - $c->_test_plugins; - - $c->res->body("ok"); -} - -sub run_time_plugins : Local { - my ( $self, $c ) = @_; - - $c->_test_plugins; - my $faux_plugin = 'Faux::Plugin'; - -# Trick perl into thinking the plugin is already loaded - $INC{'Faux/Plugin.pm'} = 1; - - __PACKAGE__->plugin( faux => $faux_plugin ); - - isa_ok $c, 'Catalyst::Plugin::Test::Plugin'; - isa_ok $c, 'TestApp::Plugin::FullyQualified'; - ok !$c->isa($faux_plugin), - '... and it should not inherit from the instant plugin'; - can_ok $c, 'faux'; - is $c->faux->count, 1, '... and it should behave correctly'; - is_deeply [ $c->registered_plugins ], - [ - qw/Catalyst::Plugin::Test::Plugin - Faux::Plugin - TestApp::Plugin::FullyQualified/ - ], - 'registered_plugins() should report all plugins'; - ok $c->registered_plugins('Faux::Plugin'), - '... and even the specific instant plugin'; - - $c->res->body("ok"); -} - sub _test_plugins { my $c = shift; is_deeply [ $c->registered_plugins ], diff --git a/t/lib/PluginTestApp/Controller/Root.pm b/t/lib/PluginTestApp/Controller/Root.pm new file mode 100644 index 0000000..e784d96 --- /dev/null +++ b/t/lib/PluginTestApp/Controller/Root.pm @@ -0,0 +1,55 @@ +package PluginTestApp::Controller::Root; +use Test::More; + +use base 'Catalyst::Controller'; + +#use Catalyst qw( +# Test::Plugin +# +TestApp::Plugin::FullyQualified +# ); + +__PACKAGE__->config->{namespace} = ''; + +sub compile_time_plugins : Local { + my ( $self, $c ) = @_; + + isa_ok $c, 'Catalyst::Plugin::Test::Plugin'; + isa_ok $c, 'TestApp::Plugin::FullyQualified'; + + can_ok $c, 'registered_plugins'; + $c->_test_plugins; + + $c->res->body("ok"); +} + +sub run_time_plugins : Local { + my ( $self, $c ) = @_; + + $c->_test_plugins; + my $faux_plugin = 'Faux::Plugin'; + +# Trick perl into thinking the plugin is already loaded + $INC{'Faux/Plugin.pm'} = 1; + + __PACKAGE__->plugin( faux => $faux_plugin ); + + isa_ok $c, 'Catalyst::Plugin::Test::Plugin'; + isa_ok $c, 'TestApp::Plugin::FullyQualified'; + ok !$c->isa($faux_plugin), + '... and it should not inherit from the instant plugin'; + can_ok $c, 'faux'; + is $c->faux->count, 1, '... and it should behave correctly'; + is_deeply [ $c->registered_plugins ], + [ + qw/Catalyst::Plugin::Test::Plugin + Faux::Plugin + TestApp::Plugin::FullyQualified/ + ], + 'registered_plugins() should report all plugins'; + ok $c->registered_plugins('Faux::Plugin'), + '... and even the specific instant plugin'; + + $c->res->body("ok"); +} + +1; diff --git a/t/lib/TestAppPluginWithConstructor.pm b/t/lib/TestAppPluginWithConstructor.pm index 36d8e16..5b4b8c1 100644 --- a/t/lib/TestAppPluginWithConstructor.pm +++ b/t/lib/TestAppPluginWithConstructor.pm @@ -6,11 +6,6 @@ use Catalyst qw/+TestPluginWithConstructor/; use Moose; BEGIN { extends qw/Catalyst Catalyst::Controller/ } # Ewww, FIXME. -sub foo : Local { - my ($self, $c) = @_; - $c->res->body('foo'); -} - __PACKAGE__->setup; our $MODIFIER_FIRED = 0; diff --git a/t/lib/TestAppPluginWithConstructor/Controller/Root.pm b/t/lib/TestAppPluginWithConstructor/Controller/Root.pm new file mode 100644 index 0000000..d032fd2 --- /dev/null +++ b/t/lib/TestAppPluginWithConstructor/Controller/Root.pm @@ -0,0 +1,12 @@ +package TestAppPluginWithConstructor::Controller::Root; + +use base 'Catalyst::Controller'; + +__PACKAGE__->config->{namespace} = ''; + +sub foo : Local { + my ($self, $c) = @_; + $c->res->body('foo'); +} + +1;