5 Test::MangleDollarUnderScore
9 +TestApp::Plugin::FullyQualified
10 +TestApp::Plugin::AddDispatchTypes
16 use namespace::autoclean;
18 our $VERSION = '0.01';
20 TestApp->config( name => 'TestApp', root => '/some/dir' );
22 if (eval { Class::MOP::load_class('CatalystX::LeakChecker'); 1 }) {
23 # with 'CatalystX::LeakChecker'; # LeakChecker dose not work yet with Catalyst::Context - zby
27 default => sub { [] },
32 my ($ctx, @leaks) = @_;
33 push @{ $ctx->leaks }, @leaks;
38 return scalar @{ $ctx->leaks };
41 TestApp->context_class( 'TestApp::Context' );
44 around prepare => sub {
48 my $c = $self->$orig(@_);
50 $c->response->header( 'X-Catalyst-Engine' => $c->engine );
51 $c->response->header( 'X-Catalyst-Debug' => $c->debug ? 1 : 0 );
54 my $components = join( ', ', sort keys %{ $c->components } );
55 $c->response->header( 'X-Catalyst-Components' => $components );
60 my $plugins = join ', ', $self->registered_plugins;
61 $c->response->header( 'X-Catalyst-Plugins' => $plugins );
69 package TestApp::Context;
71 extends 'Catalyst::Context';
75 my $class = ref( $c->component( $_[0] ) ) || $_[0];
76 my $action = $_[1]->reverse;
80 if ( $action =~ /->(\w+)$/ ) {
83 elsif ( $action =~ /\/(\w+)$/ ) {
86 elsif ( $action =~ /^(\w+)$/ ) {
90 if ( $class && $method && $method !~ /^_/ ) {
91 my $executed = sprintf( "%s->%s", $class, $method );
92 my @executed = $c->response->headers->header('X-Catalyst-Executed');
93 push @executed, $executed;
94 $c->response->headers->header(
95 'X-Catalyst-Executed' => join ', ',
99 no warnings 'recursion';
100 return $c->SUPER::execute(@_);
103 # Replace the very large HTML error page with
104 # useful info if something crashes during a test
108 $c->next::method(@_);
110 $c->res->status(500);
111 $c->res->body( 'FATAL ERROR: ' . join( ', ', @{ $c->error } ) );
114 after prepare_action => sub{
116 $c->res->header( 'X-Catalyst-Action' => $c->req->action );
122 no warnings 'redefine';
123 sub Catalyst::Log::error { }
126 # Make sure we can load Inline plugins.
128 package Catalyst::Plugin::Test::Inline;
132 use base qw/Class::Data::Inheritable/;