5 use lib "$FindBin::Bin/../lib";
9 BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; }
12 use Catalyst::Test 'TestApp';
14 if ( $ENV{CAT_BENCHMARK} ) {
16 Benchmark::timethis( $iters, \&run_tests );
26 ok( my $response = request('http://localhost/action_action_one'),
28 ok( $response->is_success, 'Response Successful 2xx' );
29 is( $response->content_type, 'text/plain', 'Response Content-Type' );
30 is( $response->header('X-Catalyst-Action'),
31 'action_action_one', 'Test Action' );
33 $response->header('X-Test-Class'),
34 'TestApp::Controller::Action::Action',
37 is( $response->header('X-Action'), 'works' );
40 qr/^bless\( .* 'Catalyst::Request' \)$/s,
41 'Content is a serialized Catalyst::Request'
46 ok( my $response = request('http://localhost/action_action_two'),
48 ok( $response->is_success, 'Response Successful 2xx' );
49 is( $response->content_type, 'text/plain', 'Response Content-Type' );
50 is( $response->header('X-Catalyst-Action'),
51 'action_action_two', 'Test Action' );
53 $response->header('X-Test-Class'),
54 'TestApp::Controller::Action::Action',
57 is( $response->header('X-Action-After'), 'awesome' );
60 qr/^bless\( .* 'Catalyst::Request' \)$/s,
61 'Content is a serialized Catalyst::Request'
68 request('http://localhost/action_action_three/one/two'),
71 ok( $response->is_success, 'Response Successful 2xx' );
72 is( $response->content_type, 'text/plain', 'Response Content-Type' );
73 is( $response->header('X-Catalyst-Action'),
74 'action_action_three', 'Test Action' );
76 $response->header('X-Test-Class'),
77 'TestApp::Controller::Action::Action',
80 is( $response->header('X-TestAppActionTestBefore'), 'one' );
83 qr/^bless\( .* 'Catalyst::Request' \)$/s,
84 'Content is a serialized Catalyst::Request'
89 ok( my $response = request('http://localhost/action_action_four'),
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_action_four', 'Test Action' );
96 $response->header('X-Test-Class'),
97 'TestApp::Controller::Action::Action',
100 is( $response->header('X-TestAppActionTestMyAction'), 'MyAction works' );
103 qr/^bless\( .* 'Catalyst::Request' \)$/s,
104 'Content is a serialized Catalyst::Request'
109 ok( my $response = request('http://localhost/action_action_five'),
111 ok( $response->is_success, 'Response Successful 2xx' );
112 is( $response->content_type, 'text/plain', 'Response Content-Type' );
113 is( $response->header('X-Catalyst-Action'),
114 'action_action_five', 'Test Action' );
116 $response->header('X-Test-Class'),
117 'TestApp::Controller::Action::Action',
120 is( $response->header('X-Action'), 'works' );
123 qr/^bless\( .* 'Catalyst::Request' \)$/s,
124 'Content is a serialized Catalyst::Request'
129 ok( my $response = request('http://localhost/action_action_six'),
131 ok( $response->is_success, 'Response Successful 2xx' );
132 is( $response->content_type, 'text/plain', 'Response Content-Type' );
133 is( $response->header('X-Catalyst-Action'),
134 'action_action_six', 'Test Action' );
136 $response->header('X-Test-Class'),
137 'TestApp::Controller::Action::Action',
140 is( $response->header('X-TestAppActionTestMyAction'), 'MyAction works' );
143 qr/^bless\( .* 'Catalyst::Request' \)$/s,
144 'Content is a serialized Catalyst::Request'
149 ok( my $response = request('http://localhost/action_action_seven'),
151 ok( $response->is_success, 'Response Successful 2xx' );
152 is( $response->content_type, 'text/plain', 'Response Content-Type' );
153 is( $response->header('X-Catalyst-Action'),
154 'action_action_seven', 'Test Action' );
156 $response->header('X-Test-Class'),
157 'TestApp::Controller::Action::Action',
160 is( $response->header('X-TestExtraArgsAction'), '42,23', 'Extra args get passed to action contstructor' );
163 qr/^bless\( .* 'Catalyst::Request' \)$/s,
164 'Content is a serialized Catalyst::Request'
169 ok( my $response = request('http://localhost/action_action_eight'),
171 ok( $response->is_success, 'Response Successful 2xx' );
172 is( $response->content_type, 'text/plain', 'Response Content-Type' );
173 is( $response->header('X-Catalyst-Action'),
174 'action_action_eight', 'Test Action' );
176 $response->header('X-Test-Class'),
177 'TestApp::Controller::Action::Action',
182 qr/^bless\( .* 'Catalyst::Action' \)$/s,
183 'Content is a serialized Catalyst::Action'
186 require Catalyst::Action; # when running against a remote server, we
187 # need to load the class in the test process
188 # to be able to introspect the action instance
190 my $action = eval $response->content;
191 is_deeply $action->attributes->{extra_attribute}, [13];
192 is_deeply $action->attributes->{another_extra_attribute}, ['foo'];
195 ok( my $response = request('http://localhost/action_action_nine'),
197 ok( $response->is_success, 'Response Successful 2xx' );
198 is( $response->content_type, 'text/plain', 'Response Content-Type' );
199 is( $response->header('X-Catalyst-Action'),
200 'action_action_nine', 'Test Action' );
202 $response->header('X-Test-Class'),
203 'TestApp::Controller::Action::Action',
206 is( $response->header('X-TestExtraArgsAction'), '42,13', 'Extra args get passed to action constructor' );
209 qr/^bless\( .* 'Catalyst::Request' \)$/s,
210 'Content is a serialized Catalyst::Request'