X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=t%2Flive%2Fcomponent%2Fcontroller%2Faction%2Fforward.t;h=db1c8eaf668c92ecd47d7f553d74e8cfe0112dd3;hp=1b7b9be61a7406e2181b9144dc608cf80525e9f0;hb=587b0f5882d4f5e128ae082758da37b065a3efde;hpb=d8c66af52b5353c93b1816e19c0f1cac69bc5ad1 diff --git a/t/live/component/controller/action/forward.t b/t/live/component/controller/action/forward.t index 1b7b9be..db1c8ea 100644 --- a/t/live/component/controller/action/forward.t +++ b/t/live/component/controller/action/forward.t @@ -6,10 +6,24 @@ use warnings; use FindBin; use lib "$FindBin::Bin/../../../lib"; -use Test::More tests => 300; +our $iters; + +BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 2; } + +use Test::More tests => 44 * $iters; use Catalyst::Test 'TestApp'; -for ( 1 .. 10 ) { +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::Forward->begin @@ -19,6 +33,7 @@ for ( 1 .. 10 ) { TestApp::Controller::Action::Forward->four TestApp::Controller::Action::Forward->five TestApp::View::Dump::Request->process + TestApp->end ]; my $expected = join( ", ", @expected ); @@ -66,6 +81,7 @@ for ( 1 .. 10 ) { TestApp::Controller::Action::Forward->four TestApp::Controller::Action::Forward->five TestApp::View::Dump::Request->process + TestApp->end ]; my $expected = join( ", ", @expected ); @@ -130,4 +146,80 @@ for ( 1 .. 10 ) { ok( $response->is_success, 'Response Successful 2xx' ); is( $response->content, 'ok' ); } + { + my @expected = qw[ + TestApp::Controller::Action::Relative->begin + TestApp::Controller::Action::Relative->relative + TestApp::Controller::Action::Forward->one + TestApp::Controller::Action::Forward->two + TestApp::Controller::Action::Forward->three + TestApp::Controller::Action::Forward->four + TestApp::Controller::Action::Forward->five + TestApp::View::Dump::Request->process + TestApp->end + ]; + + my $expected = join( ", ", @expected ); + + # Test forward to chain of actions. + ok( my $response = request('http://localhost/action/relative/relative'), + 'Request' ); + ok( $response->is_success, 'Response Successful 2xx' ); + is( $response->content_type, 'text/plain', 'Response Content-Type' ); + is( $response->header('X-Catalyst-Action'), + 'action/relative/relative', 'Test Action' ); + is( + $response->header('X-Test-Class'), + 'TestApp::Controller::Action::Relative', + 'Test Class' + ); + is( $response->header('X-Catalyst-Executed'), + $expected, 'Executed actions' ); + like( + $response->content, + qr/^bless\( .* 'Catalyst::Request' \)$/s, + 'Content is a serialized Catalyst::Request' + ); + } + { + my @expected = qw[ + TestApp::Controller::Action::Relative->begin + TestApp::Controller::Action::Relative->relative_two + TestApp::Controller::Action::Forward->one + TestApp::Controller::Action::Forward->two + TestApp::Controller::Action::Forward->three + TestApp::Controller::Action::Forward->four + TestApp::Controller::Action::Forward->five + TestApp::View::Dump::Request->process + TestApp->end + ]; + + my $expected = join( ", ", @expected ); + + # Test forward to chain of actions. + ok( + my $response = + request('http://localhost/action/relative/relative_two'), + 'Request' + ); + ok( $response->is_success, 'Response Successful 2xx' ); + is( $response->content_type, 'text/plain', 'Response Content-Type' ); + is( + $response->header('X-Catalyst-Action'), + 'action/relative/relative_two', + 'Test Action' + ); + is( + $response->header('X-Test-Class'), + 'TestApp::Controller::Action::Relative', + 'Test Class' + ); + is( $response->header('X-Catalyst-Executed'), + $expected, 'Executed actions' ); + like( + $response->content, + qr/^bless\( .* 'Catalyst::Request' \)$/s, + 'Content is a serialized Catalyst::Request' + ); + } }