Commit | Line | Data |
901367c8 |
1 | package TestApp; |
2 | |
3 | use Catalyst qw[-Engine=Test]; |
4 | |
5 | __PACKAGE__->action( |
6 | |
7 | '!begin' => sub { |
8 | my ( $self, $c ) = @_; |
9 | $c->res->headers->content_type('text/plain'); |
10 | } |
11 | ); |
12 | |
13 | package TestApp::C::Foo; |
14 | |
15 | TestApp->action( |
16 | |
17 | '!begin' => sub { |
18 | my ( $self, $c ) = @_; |
32ee1797 |
19 | $c->res->output( 'foo' ); |
901367c8 |
20 | }, |
21 | |
22 | '!default' => sub { |
23 | my ( $self, $c ) = @_; |
32ee1797 |
24 | $c->res->output( $c->res->output . 'foo' ); |
901367c8 |
25 | }, |
26 | |
27 | '!end' => sub { |
28 | my ( $self, $c ) = @_; |
32ee1797 |
29 | $c->res->output( $c->res->output . 'foo'); |
901367c8 |
30 | }, |
31 | ); |
32 | |
33 | package TestApp::C::Foo::Bar; |
34 | |
35 | TestApp->action( |
36 | |
37 | '!begin' => sub { |
38 | my ( $self, $c ) = @_; |
39 | $c->res->output( $c->res->output . 'bar' ); |
40 | }, |
41 | |
42 | '!default' => sub { |
43 | my ( $self, $c ) = @_; |
44 | $c->res->output( $c->res->output . 'bar' ); |
45 | }, |
46 | |
47 | '!end' => sub { |
48 | my ( $self, $c ) = @_; |
49 | $c->res->output( $c->res->output . 'bar' ); |
50 | }, |
51 | ); |
52 | |
53 | package main; |
54 | |
55 | use Test::More tests => 2; |
56 | use Catalyst::Test 'TestApp'; |
57 | |
58 | use Data::Dumper; |
59 | |
60 | { |
61 | my $response = request('/foo'); |
62 | ok( $response->content =~ /foofoofoo/ ); |
63 | } |
64 | |
65 | { |
66 | my $response = request('/foo/bar'); |
67 | ok( $response->content =~ /foobarfoobarfoobar/ ); |
68 | } |