Commit | Line | Data |
052a2d89 |
1 | package PluginTestApp; |
2 | use Test::More; |
3 | |
4 | use Catalyst qw( |
5 | Test::Plugin |
6 | +TestApp::Plugin::FullyQualified |
7 | ); |
8 | |
9 | sub compile_time_plugins : Local { |
10 | my ( $self, $c ) = @_; |
11 | |
12 | isa_ok $c, 'Catalyst::Plugin::Test::Plugin'; |
13 | isa_ok $c, 'TestApp::Plugin::FullyQualified'; |
14 | |
15 | can_ok $c, 'registered_plugins'; |
16 | $c->_test_plugins; |
17 | |
18 | $c->res->body("ok"); |
19 | } |
20 | |
21 | sub run_time_plugins : Local { |
22 | my ( $self, $c ) = @_; |
23 | |
24 | $c->_test_plugins; |
25 | my $faux_plugin = 'Faux::Plugin'; |
26 | |
27 | # Trick perl into thinking the plugin is already loaded |
28 | $INC{'Faux/Plugin.pm'} = 1; |
29 | |
30 | __PACKAGE__->plugin( faux => $faux_plugin ); |
31 | |
32 | isa_ok $c, 'Catalyst::Plugin::Test::Plugin'; |
33 | isa_ok $c, 'TestApp::Plugin::FullyQualified'; |
34 | ok !$c->isa($faux_plugin), |
35 | '... and it should not inherit from the instant plugin'; |
36 | can_ok $c, 'faux'; |
37 | is $c->faux->count, 1, '... and it should behave correctly'; |
38 | is_deeply [ $c->registered_plugins ], |
39 | [ |
40 | qw/Catalyst::Plugin::Test::Plugin |
41 | Faux::Plugin |
42 | TestApp::Plugin::FullyQualified/ |
43 | ], |
44 | 'registered_plugins() should report all plugins'; |
45 | ok $c->registered_plugins('Faux::Plugin'), |
46 | '... and even the specific instant plugin'; |
47 | |
48 | $c->res->body("ok"); |
49 | } |
50 | |
51 | sub _test_plugins { |
52 | my $c = shift; |
53 | is_deeply [ $c->registered_plugins ], |
54 | [ |
55 | qw/Catalyst::Plugin::Test::Plugin |
56 | TestApp::Plugin::FullyQualified/ |
57 | ], |
58 | '... and it should report the correct plugins'; |
59 | ok $c->registered_plugins('Catalyst::Plugin::Test::Plugin'), |
60 | '... or if we have a particular plugin'; |
61 | ok $c->registered_plugins('Test::Plugin'), |
62 | '... even if it is not fully qualified'; |
63 | ok !$c->registered_plugins('No::Such::Plugin'), |
64 | '... and it should return false if the plugin does not exist'; |
65 | } |
66 | |
67 | __PACKAGE__->setup; |