X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Faggregate%2Flive_component_controller_action_path.t;fp=t%2Faggregate%2Flive_component_controller_action_path.t;h=950b4ac18d48e7f5263de978eab188323a4009fa;hb=4a41d5d1ec3187cc41e15767b21c14b2aee31740;hp=0000000000000000000000000000000000000000;hpb=2757db2c7c600c8a0b8e2b4366f38c97804c2844;p=catagits%2FCatalyst-Runtime.git diff --git a/t/aggregate/live_component_controller_action_path.t b/t/aggregate/live_component_controller_action_path.t new file mode 100644 index 0000000..950b4ac --- /dev/null +++ b/t/aggregate/live_component_controller_action_path.t @@ -0,0 +1,163 @@ +#!perl + +use strict; +use warnings; + +use FindBin; +use lib "$FindBin::Bin/../lib"; + +our $iters; + +BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; } + +use Test::More tests => 42*$iters; +use Catalyst::Test 'TestApp'; + +if ( $ENV{CAT_BENCHMARK} ) { + require Benchmark; + Benchmark::timethis( $iters, \&run_tests ); +} +else { + for ( 1 .. $iters ) { + run_tests(); + } +} + +sub run_tests { + { + ok( + my $response = + request('http://localhost/action/path/a%20path%20with%20spaces'), + 'Request' + ); + ok( $response->is_success, 'Response Successful 2xx' ); + is( $response->content_type, 'text/plain', 'Response Content-Type' ); + is( + $response->header('X-Catalyst-Action'), + 'action/path/a%20path%20with%20spaces', + 'Test Action' + ); + is( + $response->header('X-Test-Class'), + 'TestApp::Controller::Action::Path', + 'Test Class' + ); + like( + $response->content, + qr/^bless\( .* 'Catalyst::Request' \)$/s, + 'Content is a serialized Catalyst::Request' + ); + } + + { + ok( my $response = request('http://localhost/action/path/åäö'), + 'Request' ); + ok( $response->is_success, 'Response Successful 2xx' ); + is( $response->content_type, 'text/plain', 'Response Content-Type' ); + is( $response->header('X-Catalyst-Action'), + 'action/path/%C3%A5%C3%A4%C3%B6', 'Test Action' ); + is( + $response->header('X-Test-Class'), + 'TestApp::Controller::Action::Path', + 'Test Class' + ); + like( + $response->content, + qr/^bless\( .* 'Catalyst::Request' \)$/s, + 'Content is a serialized Catalyst::Request' + ); + } + + { + ok( my $response = request('http://localhost/action/path/'), + 'Request' ); + ok( $response->is_success, 'Response Successful 2xx' ); + is( $response->content_type, 'text/plain', 'Response Content-Type' ); + is( $response->header('X-Catalyst-Action'), + 'action/path', 'Test Action' ); + is( + $response->header('X-Test-Class'), + 'TestApp::Controller::Action::Path', + 'Test Class' + ); + like( + $response->content, + qr/^bless\( .* 'Catalyst::Request' \)$/s, + 'Content is a serialized Catalyst::Request' + ); + } + + { + ok( my $response = request('http://localhost/action/path/spaces_near_parens_singleq'), + 'Request' ); + ok( $response->is_success, 'Response Successful 2xx' ); + is( $response->content_type, 'text/plain', 'Response Content-Type' ); + is( $response->header('X-Catalyst-Action'), + 'action/path/spaces_near_parens_singleq', 'Test Action' ); + is( + $response->header('X-Test-Class'), + 'TestApp::Controller::Action::Path', + 'Test Class' + ); + like( + $response->content, + qr/^bless\( .* 'Catalyst::Request' \)$/s, + 'Content is a serialized Catalyst::Request' + ); + } + + { + ok( my $response = request('http://localhost/action/path/spaces_near_parens_doubleq'), + 'Request' ); + ok( $response->is_success, 'Response Successful 2xx' ); + is( $response->content_type, 'text/plain', 'Response Content-Type' ); + is( $response->header('X-Catalyst-Action'), + 'action/path/spaces_near_parens_doubleq', 'Test Action' ); + is( + $response->header('X-Test-Class'), + 'TestApp::Controller::Action::Path', + 'Test Class' + ); + like( + $response->content, + qr/^bless\( .* 'Catalyst::Request' \)$/s, + 'Content is a serialized Catalyst::Request' + ); + } + + { + ok( my $response = request('http://localhost/0'), 'Request' ); + ok( $response->is_success, 'Response Successful 2xx' ); + is( $response->content_type, 'text/plain', 'Response Content-Type' ); + is( $response->header('X-Catalyst-Action'), + '0', 'Test Action' ); + is( + $response->header('X-Test-Class'), + 'TestApp::Controller::Root', + 'Test Class' + ); + like( + $response->content, + qr/^bless\( .* 'Catalyst::Request' \)$/s, + 'Content is a serialized Catalyst::Request' + ); + } + + { + ok( my $response = request('http://localhost/action/path/six'), 'Request' ); + ok( $response->is_success, 'Response Successful 2xx' ); + is( $response->content_type, 'text/plain', 'Response Content-Type' ); + is( $response->header('X-Catalyst-Action'), + 'action/path/six', 'Test Action' ); + is( + $response->header('X-Test-Class'), + 'TestApp::Controller::Action::Path', + 'Test Class' + ); + like( + $response->content, + qr/^bless\( .* 'Catalyst::Request' \)$/s, + 'Content is a serialized Catalyst::Request' + ); + } +}