7 use lib "$FindBin::Bin/../lib";
11 BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; }
14 use Catalyst::Test 'TestApp';
16 if ( $ENV{CAT_BENCHMARK} ) {
18 Benchmark::timethis( $iters, \&run_tests );
28 ok( my $response = request('http://localhost/action_action_one'),
30 ok( $response->is_success, 'Response Successful 2xx' );
31 is( $response->content_type, 'text/plain', 'Response Content-Type' );
32 is( $response->header('X-Catalyst-Action'),
33 'action_action_one', 'Test Action' );
35 $response->header('X-Test-Class'),
36 'TestApp::Controller::Action::Action',
39 is( $response->header('X-Action'), 'works' );
42 qr/^bless\( .* 'Catalyst::Request' \)$/s,
43 'Content is a serialized Catalyst::Request'
48 ok( my $response = request('http://localhost/action_action_two'),
50 ok( $response->is_success, 'Response Successful 2xx' );
51 is( $response->content_type, 'text/plain', 'Response Content-Type' );
52 is( $response->header('X-Catalyst-Action'),
53 'action_action_two', 'Test Action' );
55 $response->header('X-Test-Class'),
56 'TestApp::Controller::Action::Action',
59 is( $response->header('X-Action-After'), 'awesome' );
62 qr/^bless\( .* 'Catalyst::Request' \)$/s,
63 'Content is a serialized Catalyst::Request'
70 request('http://localhost/action_action_three/one/two'),
73 ok( $response->is_success, 'Response Successful 2xx' );
74 is( $response->content_type, 'text/plain', 'Response Content-Type' );
75 is( $response->header('X-Catalyst-Action'),
76 'action_action_three', 'Test Action' );
78 $response->header('X-Test-Class'),
79 'TestApp::Controller::Action::Action',
82 is( $response->header('X-TestAppActionTestBefore'), 'one' );
85 qr/^bless\( .* 'Catalyst::Request' \)$/s,
86 'Content is a serialized Catalyst::Request'
91 ok( my $response = request('http://localhost/action_action_four'),
93 ok( $response->is_success, 'Response Successful 2xx' );
94 is( $response->content_type, 'text/plain', 'Response Content-Type' );
95 is( $response->header('X-Catalyst-Action'),
96 'action_action_four', 'Test Action' );
98 $response->header('X-Test-Class'),
99 'TestApp::Controller::Action::Action',
102 is( $response->header('X-TestAppActionTestMyAction'), 'MyAction works' );
105 qr/^bless\( .* 'Catalyst::Request' \)$/s,
106 'Content is a serialized Catalyst::Request'
111 ok( my $response = request('http://localhost/action_action_five'),
113 ok( $response->is_success, 'Response Successful 2xx' );
114 is( $response->content_type, 'text/plain', 'Response Content-Type' );
115 is( $response->header('X-Catalyst-Action'),
116 'action_action_five', 'Test Action' );
118 $response->header('X-Test-Class'),
119 'TestApp::Controller::Action::Action',
122 is( $response->header('X-Action'), 'works' );
125 qr/^bless\( .* 'Catalyst::Request' \)$/s,
126 'Content is a serialized Catalyst::Request'
131 ok( my $response = request('http://localhost/action_action_six'),
133 ok( $response->is_success, 'Response Successful 2xx' );
134 is( $response->content_type, 'text/plain', 'Response Content-Type' );
135 is( $response->header('X-Catalyst-Action'),
136 'action_action_six', 'Test Action' );
138 $response->header('X-Test-Class'),
139 'TestApp::Controller::Action::Action',
142 is( $response->header('X-TestAppActionTestMyAction'), 'MyAction works' );
145 qr/^bless\( .* 'Catalyst::Request' \)$/s,
146 'Content is a serialized Catalyst::Request'
151 ok( my $response = request('http://localhost/action_action_seven'),
153 ok( $response->is_success, 'Response Successful 2xx' );
154 is( $response->content_type, 'text/plain', 'Response Content-Type' );
155 is( $response->header('X-Catalyst-Action'),
156 'action_action_seven', 'Test Action' );
158 $response->header('X-Test-Class'),
159 'TestApp::Controller::Action::Action',
162 is( $response->header('X-TestExtraArgsAction'), '42,23', 'Extra args get passed to action contstructor' );
165 qr/^bless\( .* 'Catalyst::Request' \)$/s,
166 'Content is a serialized Catalyst::Request'
171 ok( my $response = request('http://localhost/action_action_eight'),
173 ok( $response->is_success, 'Response Successful 2xx' );
174 is( $response->content_type, 'text/plain', 'Response Content-Type' );
175 is( $response->header('X-Catalyst-Action'),
176 'action_action_eight', 'Test Action' );
178 $response->header('X-Test-Class'),
179 'TestApp::Controller::Action::Action',
184 qr/^bless\( .* 'Catalyst::Action' \)$/s,
185 'Content is a serialized Catalyst::Action'
188 require Catalyst::Action; # when running against a remote server, we
189 # need to load the class in the test process
190 # to be able to introspect the action instance
192 my $action = eval $response->content;
193 is_deeply $action->attributes->{extra_attribute}, [13];
194 is_deeply $action->attributes->{another_extra_attribute}, ['foo'];