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