7 use lib "$FindBin::Bin/lib";
11 BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; }
13 use Test::More tests => 50 * $iters;
14 use Catalyst::Test 'TestApp';
16 if ( $ENV{CAT_BENCHMARK} ) {
18 Benchmark::timethis( $iters, \&run_tests );
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
39 my $expected = join( ", ", @expected );
41 # Test forward to global private action
42 ok( my $response = request('http://localhost/action/forward/global'),
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' );
49 # Test forward to chain of actions.
50 ok( $response = request('http://localhost/action/forward/one'),
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' );
57 $response->header('X-Test-Class'),
58 'TestApp::Controller::Action::Forward',
61 is( $response->header('X-Catalyst-Executed'),
62 $expected, 'Executed actions' );
65 qr/^bless\( .* 'Catalyst::Request' \)$/s,
66 'Content is a serialized Catalyst::Request'
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
87 my $expected = join( ", ", @expected );
89 ok( my $response = request('http://localhost/action/forward/jojo'),
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' );
96 $response->header('X-Test-Class'),
97 'TestApp::Controller::Action::Forward',
100 is( $response->header('X-Catalyst-Executed'),
101 $expected, 'Executed actions' );
104 qr/^bless\( .* 'Catalyst::Request' \)$/s,
105 'Content is a serialized Catalyst::Request'
112 request('http://localhost/action/forward/with_args/old'),
115 ok( $response->is_success, 'Response Successful 2xx' );
116 is( $response->content, 'old' );
121 my $response = request(
122 'http://localhost/action/forward/with_method_and_args/old'),
123 'Request with args and method'
125 ok( $response->is_success, 'Response Successful 2xx' );
126 is( $response->content, 'old' );
129 # test forward with embedded args
133 request('http://localhost/action/forward/args_embed_relative'),
136 ok( $response->is_success, 'Response Successful 2xx' );
137 is( $response->content, 'ok' );
143 request('http://localhost/action/forward/args_embed_absolute'),
146 ok( $response->is_success, 'Response Successful 2xx' );
147 is( $response->content, 'ok' );
151 TestApp::Controller::Action::TestRelative->begin
152 TestApp::Controller::Action::TestRelative->relative
153 TestApp::Controller::Action::Forward->one
154 TestApp::Controller::Action::Forward->two
155 TestApp::Controller::Action::Forward->three
156 TestApp::Controller::Action::Forward->four
157 TestApp::Controller::Action::Forward->five
158 TestApp::View::Dump::Request->process
162 my $expected = join( ", ", @expected );
164 # Test forward to chain of actions.
165 ok( my $response = request('http://localhost/action/relative/relative'),
167 ok( $response->is_success, 'Response Successful 2xx' );
168 is( $response->content_type, 'text/plain', 'Response Content-Type' );
169 is( $response->header('X-Catalyst-Action'),
170 'action/relative/relative', 'Test Action' );
172 $response->header('X-Test-Class'),
173 'TestApp::Controller::Action::TestRelative',
176 is( $response->header('X-Catalyst-Executed'),
177 $expected, 'Executed actions' );
180 qr/^bless\( .* 'Catalyst::Request' \)$/s,
181 'Content is a serialized Catalyst::Request'
186 TestApp::Controller::Action::TestRelative->begin
187 TestApp::Controller::Action::TestRelative->relative_two
188 TestApp::Controller::Action::Forward->one
189 TestApp::Controller::Action::Forward->two
190 TestApp::Controller::Action::Forward->three
191 TestApp::Controller::Action::Forward->four
192 TestApp::Controller::Action::Forward->five
193 TestApp::View::Dump::Request->process
197 my $expected = join( ", ", @expected );
199 # Test forward to chain of actions.
202 request('http://localhost/action/relative/relative_two'),
205 ok( $response->is_success, 'Response Successful 2xx' );
206 is( $response->content_type, 'text/plain', 'Response Content-Type' );
208 $response->header('X-Catalyst-Action'),
209 'action/relative/relative_two',
213 $response->header('X-Test-Class'),
214 'TestApp::Controller::Action::TestRelative',
217 is( $response->header('X-Catalyst-Executed'),
218 $expected, 'Executed actions' );
221 qr/^bless\( .* 'Catalyst::Request' \)$/s,
222 'Content is a serialized Catalyst::Request'
226 # test class forwards
229 my $response = request(
230 'http://localhost/action/forward/class_forward_test_action'),
233 ok( $response->is_success, 'Response Successful 2xx' );
234 is( $response->header('X-Class-Forward-Test-Method'), 1,
238 # test uri_for re r7385
240 ok( my $response = request(
241 'http://localhost/action/forward/forward_to_uri_check'),
242 'forward_to_uri_check request');
244 ok( $response->is_success, 'forward_to_uri_check successful');
245 is( $response->content, '/action/forward/foo/bar',
246 'forward_to_uri_check correct namespace');