Create branch register_actions.
[catagits/Catalyst-Runtime.git] / t / lib / Catalyst / Plugin / Test / Plugin.pm
CommitLineData
fbcc39ad 1package Catalyst::Plugin::Test::Plugin;
2
3use strict;
ae29b412 4use warnings;
5use MRO::Compat;
fbcc39ad 6
01ba879f 7use base qw/Catalyst::Base Class::Data::Inheritable/;
fbcc39ad 8
9 __PACKAGE__->mk_classdata('ran_setup');
10
11sub setup {
12 my $c = shift;
13 $c->ran_setup('1');
14}
15
16sub prepare {
17
18 my $class = shift;
19
ae29b412 20# Note: This use of NEXT is deliberately left here (without a use NEXT)
21# to ensure back compat, as NEXT always used to be loaded, but
22# is now replaced by Class::C3::Adopt::NEXT.
fbcc39ad 23 my $c = $class->NEXT::prepare(@_);
24 $c->response->header( 'X-Catalyst-Plugin-Setup' => $c->ran_setup );
25
26 return $c;
27
28}
29
ae29b412 30# Note: This is horrible, but Catalyst::Plugin::Server forces the body to
31# be parsed, by calling the $c->req->body method in prepare_action.
32# We need to test this, as this was broken by 5.80. See also
33# t/aggregate/live_engine_request_body.t. Better ways to test this
34# appreciated if you have suggestions :)
35{
36 my $have_req_body = 0;
37 sub prepare_action {
38 my $c = shift;
39 $have_req_body++ if $c->req->body;
40 $c->next::method(@_);
41 }
42 sub have_req_body_in_prepare_action : Local {
43 my ($self, $c) = @_;
44 $c->res->body($have_req_body);
45 }
46}
47
01ba879f 48sub end : Private {
49 my ($self,$c) = @_;
50}
51
fbcc39ad 521;