Create branch register_actions.
[catagits/Catalyst-Runtime.git] / t / lib / Catalyst / Plugin / Test / Plugin.pm
index 62b2cad..5cb6e4a 100644 (file)
@@ -1,6 +1,8 @@
 package Catalyst::Plugin::Test::Plugin;
 
 use strict;
+use warnings;
+use MRO::Compat;
 
 use base qw/Catalyst::Base Class::Data::Inheritable/;
 
@@ -15,6 +17,9 @@ sub  prepare {
 
     my $class = shift;
 
+# Note: This use of NEXT is deliberately left here (without a use NEXT)
+#       to ensure back compat, as NEXT always used to be loaded, but 
+#       is now replaced by Class::C3::Adopt::NEXT.
     my $c = $class->NEXT::prepare(@_);
     $c->response->header( 'X-Catalyst-Plugin-Setup' => $c->ran_setup );
 
@@ -22,6 +27,24 @@ sub  prepare {
 
 }
 
+# Note: This is horrible, but Catalyst::Plugin::Server forces the body to
+#       be parsed, by calling the $c->req->body method in prepare_action.
+#       We need to test this, as this was broken by 5.80. See also
+#       t/aggregate/live_engine_request_body.t. Better ways to test this
+#       appreciated if you have suggestions :)
+{
+    my $have_req_body = 0;
+    sub prepare_action {
+        my $c = shift;
+        $have_req_body++ if $c->req->body;
+        $c->next::method(@_);
+    }
+    sub have_req_body_in_prepare_action : Local {
+        my ($self, $c) = @_;
+        $c->res->body($have_req_body);
+    }
+}
+
 sub end : Private {
     my ($self,$c) = @_;
 }