1 # Test that plugins with their own new method don't break applications.
3 # 5.70 creates all of the request/response structure itself in prepare,
4 # and as the new method in our plugin just blesses our args, that works nicely.
6 # In 5.80, we rely on the new method to appropriately initialise data
7 # structures, and therefore we need to inline a new method on MyApp to ensure
8 # that plugins don't get it wrong for us.
10 # Also tests method modifiers and etc in MyApp.pm still work as expected.
11 use Test::More tests => 3;
14 package NewTestPlugin;
19 return bless $_[0], $class;
23 { # This is all in the same file so that the setup method on the
24 # application is called at runtime, rather than at compile time.
25 # This ensures that the end of scope hook has to happen at runtime
26 # correctly, otherwise the test will fail (ergo the switch from
27 # B::Hooks::EndOfScope to Sub::Uplevel)
28 package TestAppPluginWithNewMethod;
30 use Catalyst qw/+NewTestPlugin/;
37 use Moose; # Just testing method modifiers still work.
39 our $MODIFIER_FIRED = 0;
42 before 'dispatch' => sub { $MODIFIER_FIRED = 1 }
43 } 'Can apply method modifier';
48 use lib "$FindBin::Bin/lib";
50 use Catalyst::Test qw/TestAppPluginWithNewMethod/;
51 ok request('/foo')->is_success;
52 is $TestAppPluginWithNewMethod::MODIFIER_FIRED, 1, 'Before modifier was fired correctly.';