prepared for 5.58
[catagits/Catalyst-Runtime.git] / t / lib / TestApp.pm
CommitLineData
dd4e6fd2 1package TestApp;
2
3use strict;
fbcc39ad 4use Catalyst qw/Test::Errors Test::Headers Test::Plugin/;
1408d0a4 5use Catalyst::Utils;
dd4e6fd2 6
7our $VERSION = '0.01';
8
fbcc39ad 9TestApp->config( name => 'TestApp', root => '/some/dir' );
dd4e6fd2 10
11TestApp->setup;
12
e0e47c71 13sub index : Private {
14 my ( $self, $c ) = @_;
369c09bc 15 $c->res->body('root index');
e0e47c71 16}
17
e5d7f18c 18sub global_action : Private {
2656a6de 19 my ( $self, $c ) = @_;
20 $c->forward('TestApp::View::Dump::Request');
21}
22
dd4e6fd2 23sub execute {
4d989a5d 24 my $c = shift;
25 my $class = ref( $c->component( $_[0] ) ) || $_[0];
fbcc39ad 26 my $action = "$_[1]";
dd4e6fd2 27
28 my $method;
29
4d989a5d 30 if ( $action =~ /->(\w+)$/ ) {
31 $method = $1;
dd4e6fd2 32 }
4d989a5d 33 elsif ( $action =~ /\/(\w+)$/ ) {
34 $method = $1;
dd4e6fd2 35 }
01ba879f 36 elsif ( $action =~ /^(\w+)$/ ) {
37 $method = $action;
38 }
39
ba599d1c 40 if ( $class && $method && $method !~ /^_/ ) {
1408d0a4 41 my $executed = sprintf( "%s->%s", $class, $method );
fbcc39ad 42 my @executed = $c->response->headers->header('X-Catalyst-Executed');
43 push @executed, $executed;
44 $c->response->headers->header(
45 'X-Catalyst-Executed' => join ', ',
46 @executed
47 );
1408d0a4 48 }
fbcc39ad 49
dd4e6fd2 50 return $c->SUPER::execute(@_);
51}
52
369c09bc 53{
54 no warnings 'redefine';
55 sub Catalyst::Log::error { }
56}
dd4e6fd2 571;