Commit | Line | Data |
dd4e6fd2 |
1 | #!perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use FindBin; |
9770ad56 |
7 | use lib "$FindBin::Bin/../../../lib"; |
dd4e6fd2 |
8 | |
232fd394 |
9 | our $iters; |
10 | |
11 | BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 2; } |
12 | |
13 | use Test::More tests => 30*$iters; |
dd4e6fd2 |
14 | use Catalyst::Test 'TestApp'; |
15 | |
232fd394 |
16 | if ( $ENV{CAT_BENCHMARK} ) { |
17 | require Benchmark; |
5a6c7ff6 |
18 | Benchmark::timethis( $iters, \&run_tests ); |
232fd394 |
19 | } |
20 | else { |
21 | for ( 1 .. $iters ) { |
22 | run_tests(); |
23 | } |
24 | } |
25 | |
26 | sub run_tests { |
d8c66af5 |
27 | { |
28 | my @expected = qw[ |
29 | TestApp::Controller::Action::Forward->begin |
30 | TestApp::Controller::Action::Forward->one |
31 | TestApp::Controller::Action::Forward->two |
32 | TestApp::Controller::Action::Forward->three |
33 | TestApp::Controller::Action::Forward->four |
34 | TestApp::Controller::Action::Forward->five |
35 | TestApp::View::Dump::Request->process |
01ba879f |
36 | TestApp->end |
d8c66af5 |
37 | ]; |
dd4e6fd2 |
38 | |
d8c66af5 |
39 | my $expected = join( ", ", @expected ); |
dd4e6fd2 |
40 | |
d8c66af5 |
41 | # Test forward to global private action |
42 | ok( my $response = request('http://localhost/action/forward/global'), |
43 | 'Request' ); |
44 | ok( $response->is_success, 'Response Successful 2xx' ); |
45 | is( $response->content_type, 'text/plain', 'Response Content-Type' ); |
46 | is( $response->header('X-Catalyst-Action'), |
47 | 'action/forward/global', 'Main Class Action' ); |
40392ee9 |
48 | |
d8c66af5 |
49 | # Test forward to chain of actions. |
50 | ok( $response = request('http://localhost/action/forward/one'), |
51 | 'Request' ); |
52 | ok( $response->is_success, 'Response Successful 2xx' ); |
53 | is( $response->content_type, 'text/plain', 'Response Content-Type' ); |
54 | is( $response->header('X-Catalyst-Action'), |
55 | 'action/forward/one', 'Test Action' ); |
56 | is( |
57 | $response->header('X-Test-Class'), |
58 | 'TestApp::Controller::Action::Forward', |
59 | 'Test Class' |
60 | ); |
61 | is( $response->header('X-Catalyst-Executed'), |
62 | $expected, 'Executed actions' ); |
63 | like( |
64 | $response->content, |
65 | qr/^bless\( .* 'Catalyst::Request' \)$/s, |
66 | 'Content is a serialized Catalyst::Request' |
67 | ); |
68 | } |
dd4e6fd2 |
69 | |
d8c66af5 |
70 | { |
71 | my @expected = qw[ |
72 | TestApp::Controller::Action::Forward->begin |
73 | TestApp::Controller::Action::Forward->jojo |
74 | TestApp::Controller::Action::Forward->one |
75 | TestApp::Controller::Action::Forward->two |
76 | TestApp::Controller::Action::Forward->three |
77 | TestApp::Controller::Action::Forward->four |
78 | TestApp::Controller::Action::Forward->five |
79 | TestApp::View::Dump::Request->process |
80 | TestApp::Controller::Action::Forward->three |
81 | TestApp::Controller::Action::Forward->four |
82 | TestApp::Controller::Action::Forward->five |
83 | TestApp::View::Dump::Request->process |
01ba879f |
84 | TestApp->end |
d8c66af5 |
85 | ]; |
dd4e6fd2 |
86 | |
d8c66af5 |
87 | my $expected = join( ", ", @expected ); |
dd4e6fd2 |
88 | |
d8c66af5 |
89 | ok( my $response = request('http://localhost/action/forward/jojo'), |
90 | 'Request' ); |
91 | ok( $response->is_success, 'Response Successful 2xx' ); |
92 | is( $response->content_type, 'text/plain', 'Response Content-Type' ); |
93 | is( $response->header('X-Catalyst-Action'), |
94 | 'action/forward/jojo', 'Test Action' ); |
95 | is( |
96 | $response->header('X-Test-Class'), |
97 | 'TestApp::Controller::Action::Forward', |
98 | 'Test Class' |
99 | ); |
100 | is( $response->header('X-Catalyst-Executed'), |
101 | $expected, 'Executed actions' ); |
102 | like( |
103 | $response->content, |
104 | qr/^bless\( .* 'Catalyst::Request' \)$/s, |
105 | 'Content is a serialized Catalyst::Request' |
106 | ); |
107 | } |
a1dad9c1 |
108 | |
d8c66af5 |
109 | { |
110 | ok( |
111 | my $response = |
112 | request('http://localhost/action/forward/with_args/old'), |
113 | 'Request with args' |
114 | ); |
115 | ok( $response->is_success, 'Response Successful 2xx' ); |
116 | is( $response->content, 'old' ); |
117 | } |
a1dad9c1 |
118 | |
d8c66af5 |
119 | { |
120 | ok( |
121 | my $response = request( |
122 | 'http://localhost/action/forward/with_method_and_args/old'), |
123 | 'Request with args and method' |
124 | ); |
125 | ok( $response->is_success, 'Response Successful 2xx' ); |
126 | is( $response->content, 'old' ); |
127 | } |
ab96c27a |
128 | |
d8c66af5 |
129 | # test forward with embedded args |
130 | { |
131 | ok( |
132 | my $response = |
133 | request('http://localhost/action/forward/args_embed_relative'), |
134 | 'Request' |
135 | ); |
136 | ok( $response->is_success, 'Response Successful 2xx' ); |
137 | is( $response->content, 'ok' ); |
138 | } |
40392ee9 |
139 | |
d8c66af5 |
140 | { |
141 | ok( |
142 | my $response = |
143 | request('http://localhost/action/forward/args_embed_absolute'), |
144 | 'Request' |
145 | ); |
146 | ok( $response->is_success, 'Response Successful 2xx' ); |
147 | is( $response->content, 'ok' ); |
148 | } |
a1dad9c1 |
149 | } |