6 use Test::More tests => 22;
14 sub new { bless {}, shift }
16 sub count { $count++ }
21 package PluginTestApp;
26 +TestApp::Plugin::FullyQualified
29 sub compile_time_plugins : Local {
30 my ( $self, $c ) = @_;
32 isa_ok $c, 'Catalyst::Plugin::Test::Plugin';
33 isa_ok $c, 'TestApp::Plugin::FullyQualified';
35 can_ok $c, 'registered_plugins';
41 sub run_time_plugins : Local {
42 my ( $self, $c ) = @_;
45 my $faux_plugin = 'Faux::Plugin';
47 # Trick perl into thinking the plugin is already loaded
48 $INC{'Faux/Plugin.pm'} = 1;
50 __PACKAGE__->plugin( faux => $faux_plugin );
52 isa_ok $c, 'Catalyst::Plugin::Test::Plugin';
53 isa_ok $c, 'TestApp::Plugin::FullyQualified';
54 ok !$c->isa($faux_plugin),
55 '... and it should not inherit from the instant plugin';
57 is $c->faux->count, 1, '... and it should behave correctly';
58 is_deeply [ $c->registered_plugins ],
60 qw/Catalyst::Plugin::Test::Plugin
62 TestApp::Plugin::FullyQualified/
64 'registered_plugins() should report all plugins';
65 ok $c->registered_plugins('Faux::Plugin'),
66 '... and even the specific instant plugin';
73 is_deeply [ $c->registered_plugins ],
75 qw/Catalyst::Plugin::Test::Plugin
76 TestApp::Plugin::FullyQualified/
78 '... and it should report the correct plugins';
79 ok $c->registered_plugins('Catalyst::Plugin::Test::Plugin'),
80 '... or if we have a particular plugin';
81 ok $c->registered_plugins('Test::Plugin'),
82 '... even if it is not fully qualified';
83 ok !$c->registered_plugins('No::Such::Plugin'),
84 '... and it should return false if the plugin does not exist';
90 use Catalyst::Test qw/PluginTestApp/;
92 ok( get("/compile_time_plugins"), "get ok" );
93 ok( get("/run_time_plugins"), "get ok" );
97 Catalyst::Plugin::Test::Errors
98 Catalyst::Plugin::Test::Headers
99 Catalyst::Plugin::Test::Plugin
100 TestApp::Plugin::FullyQualified
103 # Faux::Plugin is no longer reported
104 is_deeply [ TestApp->registered_plugins ], \@expected,
105 'registered_plugins() should only report the plugins for the current class';