Commit | Line | Data |
---|---|---|
dd4e6fd2 | 1 | package TestApp; |
2 | ||
3 | use strict; | |
fbcc39ad | 4 | use Catalyst qw/Test::Errors Test::Headers Test::Plugin/; |
1408d0a4 | 5 | use Catalyst::Utils; |
dd4e6fd2 | 6 | |
7 | our $VERSION = '0.01'; | |
8 | ||
fbcc39ad | 9 | TestApp->config( name => 'TestApp', root => '/some/dir' ); |
dd4e6fd2 | 10 | |
11 | TestApp->setup; | |
12 | ||
e0e47c71 | 13 | sub index : Private { |
14 | my ( $self, $c ) = @_; | |
369c09bc | 15 | $c->res->body('root index'); |
e0e47c71 | 16 | } |
17 | ||
e5d7f18c | 18 | sub global_action : Private { |
2656a6de | 19 | my ( $self, $c ) = @_; |
20 | $c->forward('TestApp::View::Dump::Request'); | |
21 | } | |
22 | ||
dd4e6fd2 | 23 | sub 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 | ||
86d993ab | 53 | sub class_forward_test_method { |
54 | my ( $self, $c ) = @_; | |
55 | $c->response->headers->header( 'X-Class-Forward-Test-Method' => 1 ); | |
56 | } | |
57 | ||
369c09bc | 58 | { |
59 | no warnings 'redefine'; | |
60 | sub Catalyst::Log::error { } | |
61 | } | |
dd4e6fd2 | 62 | 1; |