1 package TestApp::Context;
3 extends 'Catalyst::Context';
4 with 'Catalyst::TraitFor::Context::TestHeaders',
5 'Catalyst::TraitFor::Context::TestErrors',
6 'Catalyst::TraitFor::Context::TestPluginServer';
8 if (eval { Class::MOP::load_class('CatalystX::LeakChecker'); 1 }) {
9 with 'CatalystX::LeakChecker';
13 default => sub { [] },
18 my ($ctx, @leaks) = @_;
19 push @{ $ctx->leaks }, @leaks;
24 return scalar @{ $ctx->leaks };
29 my $class = ref( $c->component( $_[0] ) ) || $_[0];
30 my $action = $_[1]->reverse;
34 if ( $action =~ /->(\w+)$/ ) {
37 elsif ( $action =~ /\/(\w+)$/ ) {
40 elsif ( $action =~ /^(\w+)$/ ) {
44 if ( $class && $method && $method !~ /^_/ ) {
45 my $executed = sprintf( "%s->%s", $class, $method );
46 my @executed = $c->response->headers->header('X-Catalyst-Executed');
47 push @executed, $executed;
48 $c->response->headers->header(
49 'X-Catalyst-Executed' => join ', ',
53 no warnings 'recursion';
54 return $c->SUPER::execute(@_);
57 # Replace the very large HTML error page with
58 # useful info if something crashes during a test
65 $c->res->body( 'FATAL ERROR: ' . join( ', ', @{ $c->error } ) );