adding test case contributed by nebulous
[catagits/Catalyst-Plugin-SubRequest.git] / t / lib / TestApp / Controller / Root.pm
CommitLineData
61114b68 1package TestApp::Controller::Root;
2use strict;
3use warnings;
4
5use base qw/Catalyst::Controller/;
6
7sub begin : Private {
8 my ( $self, $c ) = @_;
9 $c->res->body('1');
10}
11
12sub subtest : Global {
13 my ( $self, $c ) = @_;
14 my $subreq= $c->res->body().
15 $c->subreq('/normal/4');
16 $c->res->body($subreq);
17}
18
19sub normal : Global {
20 my ( $self, $c, $arg ) = @_;
21 $c->res->body($c->res->body().$arg);
22}
23
24sub subtest_params : Global {
25 my ( $self, $c ) = @_;
26 my $before = $c->req->params->{value};
27 my $subreq = $c->subreq('/normal/2');
28 my $after = $c->req->params->{value};
29 $c->res->body($c->res->body().$after);
30}
31
5d6707eb 32sub subtest_req : Global {
33 my ( $self, $c ) = @_;
34 my $subreq = $c->subreq('/normal/2');
35 my $after = $c->req->uri->path;
36 $c->res->body($after);
37}
38
87c672db 39sub subtest_full_response : Global {
40 my ( $self, $c ) = @_;
41 my $subreq_res = $c->subreq_res('/typesetter');
42 $c->res->body( $c->res->body() . $subreq_res->content_type );
43}
44
f3f2edc9 45sub subtest_with_params :Global {
46 my($self, $c) = @_;
47 $c->res->body(
48 $c->subrequest('/plain_param', {},
49 { content => 'foo' }));
50}
51
52sub plain_param :Global {
53 my($self, $c) = @_;
54 $c->res->body($c->req->params->{content});
55}
56
87c672db 57sub typesetter : Global {
58 my ( $self, $c, $arg ) = @_;
59 $c->res->content_type( 'text/csv' );
60 $c->res->body($c->res->body());
61}
62
8fb9227b 63sub doublesubtest :Global {
64 my ( $self, $c) = @_;
65 $c->res->body(
66 $c->subrequest('/normal/5').
67 $c->subrequest('/normal/6')
68 );
69}
70
61114b68 71sub end : Private {
72 my ( $self, $c ) = @_;
73 $c->res->body($c->res->body().'3');
74}
75
761;
77