X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flive_component_controller_action_detach.t;h=58967931b39db7fb94a9523b52a367f7ae5d8e46;hb=f04fdedae056296d0fa97fbdcaa85b9811ca6a5b;hp=42a9fe01f7177f50ef662c542d644db7615ef6f5;hpb=a2e038a1e9cbc0f1ea32b7087e6b47efe3af082f;p=catagits%2FCatalyst-Runtime.git diff --git a/t/live_component_controller_action_detach.t b/t/live_component_controller_action_detach.t index 42a9fe0..5896793 100644 --- a/t/live_component_controller_action_detach.t +++ b/t/live_component_controller_action_detach.t @@ -1,100 +1,100 @@ -#!perl - -use strict; -use warnings; - -use FindBin; -use lib "$FindBin::Bin/lib"; - -our $iters; - -BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 2; } - -use Test::More tests => 18*$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 { - { - my @expected = qw[ - TestApp::Controller::Action::Detach->begin - TestApp::Controller::Action::Detach->one - TestApp::Controller::Action::Detach->two - TestApp::View::Dump::Request->process - TestApp->end - ]; - - my $expected = join( ", ", @expected ); - - # Test detach to chain of actions. - ok( my $response = request('http://localhost/action/detach/one'), - 'Request' ); - ok( $response->is_success, 'Response Successful 2xx' ); - is( $response->content_type, 'text/plain', 'Response Content-Type' ); - is( $response->header('X-Catalyst-Action'), - 'action/detach/one', 'Test Action' ); - is( - $response->header('X-Test-Class'), - 'TestApp::Controller::Action::Detach', - 'Test Class' - ); - is( $response->header('X-Catalyst-Executed'), - $expected, 'Executed actions' ); - } - - { - my @expected = qw[ - TestApp::Controller::Action::Detach->begin - TestApp::Controller::Action::Detach->path - TestApp::Controller::Action::Detach->two - TestApp::View::Dump::Request->process - TestApp->end - ]; - - my $expected = join( ", ", @expected ); - - # Test detach to chain of actions. - ok( my $response = request('http://localhost/action/detach/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/detach/path', 'Test Action' ); - is( - $response->header('X-Test-Class'), - 'TestApp::Controller::Action::Detach', - 'Test Class' - ); - is( $response->header('X-Catalyst-Executed'), - $expected, 'Executed actions' ); - } - - { - ok( - my $response = - request('http://localhost/action/detach/with_args/old'), - 'Request with args' - ); - ok( $response->is_success, 'Response Successful 2xx' ); - is( $response->content, 'new' ); - } - - { - ok( - my $response = request( - 'http://localhost/action/detach/with_method_and_args/old'), - 'Request with args and method' - ); - ok( $response->is_success, 'Response Successful 2xx' ); - is( $response->content, 'new' ); - } -} +#!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 => 18*$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 { + { + my @expected = qw[ + TestApp::Controller::Action::Detach->begin + TestApp::Controller::Action::Detach->one + TestApp::Controller::Action::Detach->two + TestApp::View::Dump::Request->process + TestApp->end + ]; + + my $expected = join( ", ", @expected ); + + # Test detach to chain of actions. + ok( my $response = request('http://localhost/action/detach/one'), + 'Request' ); + ok( $response->is_success, 'Response Successful 2xx' ); + is( $response->content_type, 'text/plain', 'Response Content-Type' ); + is( $response->header('X-Catalyst-Action'), + 'action/detach/one', 'Test Action' ); + is( + $response->header('X-Test-Class'), + 'TestApp::Controller::Action::Detach', + 'Test Class' + ); + is( $response->header('X-Catalyst-Executed'), + $expected, 'Executed actions' ); + } + + { + my @expected = qw[ + TestApp::Controller::Action::Detach->begin + TestApp::Controller::Action::Detach->path + TestApp::Controller::Action::Detach->two + TestApp::View::Dump::Request->process + TestApp->end + ]; + + my $expected = join( ", ", @expected ); + + # Test detach to chain of actions. + ok( my $response = request('http://localhost/action/detach/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/detach/path', 'Test Action' ); + is( + $response->header('X-Test-Class'), + 'TestApp::Controller::Action::Detach', + 'Test Class' + ); + is( $response->header('X-Catalyst-Executed'), + $expected, 'Executed actions' ); + } + + { + ok( + my $response = + request('http://localhost/action/detach/with_args/old'), + 'Request with args' + ); + ok( $response->is_success, 'Response Successful 2xx' ); + is( $response->content, 'new' ); + } + + { + ok( + my $response = request( + 'http://localhost/action/detach/with_method_and_args/old'), + 'Request with args and method' + ); + ok( $response->is_success, 'Response Successful 2xx' ); + is( $response->content, 'new' ); + } +}