More actions moved to root controllers.
[catagits/Catalyst-Runtime.git] / t / lib / PluginTestApp / Controller / Root.pm
CommitLineData
9d04b685 1package PluginTestApp::Controller::Root;
2use Test::More;
3
4use base 'Catalyst::Controller';
5
6#use Catalyst qw(
7# Test::Plugin
8# +TestApp::Plugin::FullyQualified
9# );
10
11__PACKAGE__->config->{namespace} = '';
12
13sub compile_time_plugins : Local {
14 my ( $self, $c ) = @_;
15
16 isa_ok $c, 'Catalyst::Plugin::Test::Plugin';
17 isa_ok $c, 'TestApp::Plugin::FullyQualified';
18
19 can_ok $c, 'registered_plugins';
20 $c->_test_plugins;
21
22 $c->res->body("ok");
23}
24
25sub run_time_plugins : Local {
26 my ( $self, $c ) = @_;
27
28 $c->_test_plugins;
29 my $faux_plugin = 'Faux::Plugin';
30
31# Trick perl into thinking the plugin is already loaded
32 $INC{'Faux/Plugin.pm'} = 1;
33
34 __PACKAGE__->plugin( faux => $faux_plugin );
35
36 isa_ok $c, 'Catalyst::Plugin::Test::Plugin';
37 isa_ok $c, 'TestApp::Plugin::FullyQualified';
38 ok !$c->isa($faux_plugin),
39 '... and it should not inherit from the instant plugin';
40 can_ok $c, 'faux';
41 is $c->faux->count, 1, '... and it should behave correctly';
42 is_deeply [ $c->registered_plugins ],
43 [
44 qw/Catalyst::Plugin::Test::Plugin
45 Faux::Plugin
46 TestApp::Plugin::FullyQualified/
47 ],
48 'registered_plugins() should report all plugins';
49 ok $c->registered_plugins('Faux::Plugin'),
50 '... and even the specific instant plugin';
51
52 $c->res->body("ok");
53}
54
551;