X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=t%2Flive_component_controller_action_chained.t;h=a8b7e09ab97f0246ae7ea3f82400e68093379c51;hp=708fc675616486d1664cecd4adf6afb00db1f477;hb=2f3812528068bc1d9f7840067f0c03d36cd47e6d;hpb=afb82794328ff8da1efc0a4c37f3f3703c262c31 diff --git a/t/live_component_controller_action_chained.t b/t/live_component_controller_action_chained.t index 708fc67..a8b7e09 100644 --- a/t/live_component_controller_action_chained.t +++ b/t/live_component_controller_action_chained.t @@ -10,7 +10,7 @@ our $iters; BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; } -use Test::More tests => 124*$iters; +use Test::More tests => 141*$iters; use Catalyst::Test 'TestApp'; if ( $ENV{CAT_BENCHMARK} ) { @@ -528,6 +528,86 @@ sub run_tests { } # + # Test if :Chained('../act') is working + # + { + my @expected = qw[ + TestApp::Controller::Action::Chained->begin + TestApp::Controller::Action::Chained->one + TestApp::Controller::Action::Chained::ParentChain->chained_rel + TestApp::Controller::Action::Chained->end + ]; + + my $expected = join( ", ", @expected ); + + ok( my $response = request('http://localhost/chained/one/1/chained_rel/3/2'), + ":Chained('../action') chains to correct action" ); + is( $response->header('X-Catalyst-Executed'), + $expected, 'Executed actions' ); + is( $response->content, '1; 3, 2', 'Content OK' ); + } + + # + # Test if ../ works to go up more than one level + # + { + my @expected = qw[ + TestApp::Controller::Action::Chained->begin + TestApp::Controller::Action::Chained->one + TestApp::Controller::Action::Chained::ParentChain::Relative->chained_rel_two + TestApp::Controller::Action::Chained->end + ]; + + my $expected = join( ", ", @expected ); + + ok( my $response = request('http://localhost/chained/one/1/chained_rel_two/42/23'), + "../ works to go up more than one level" ); + is( $response->header('X-Catalyst-Executed'), + $expected, 'Executed actions' ); + is( $response->content, '1; 42, 23', 'Content OK' ); + } + + # + # Test if :ChainedParent is working + # + { + my @expected = qw[ + TestApp::Controller::Action::Chained->begin + TestApp::Controller::Action::Chained->loose + TestApp::Controller::Action::Chained::ParentChain->loose + TestApp::Controller::Action::Chained->end + ]; + + my $expected = join( ", ", @expected ); + + ok( my $response = request('http://localhost/chained/loose/4/loose/a/b'), + ":Chained('../action') chains to correct action" ); + is( $response->header('X-Catalyst-Executed'), + $expected, 'Executed actions' ); + is( $response->content, '4; a, b', 'Content OK' ); + } + + # + # Test if :Chained('../name/act') is working + # + { + my @expected = qw[ + TestApp::Controller::Action::Chained->begin + TestApp::Controller::Action::Chained::Bar->cross1 + TestApp::Controller::Action::Chained::ParentChain->up_down + TestApp::Controller::Action::Chained->end + ]; + + my $expected = join( ", ", @expected ); + + ok( my $response = request('http://localhost/chained/cross/4/up_down/5'), + ":Chained('../action') chains to correct action" ); + is( $response->header('X-Catalyst-Executed'), + $expected, 'Executed actions' ); + is( $response->content, '4; 5', 'Content OK' ); + } + + # # Test behaviour of auto actions returning '1' for the chain. # { @@ -863,4 +943,42 @@ sub run_tests { } + # + # PathPrefix + # + { + my @expected = qw[ + TestApp::Controller::Action::Chained->begin + TestApp::Controller::Action::Chained::PathPrefix->instance + TestApp::Controller::Action::Chained->end + ]; + + my $expected = join( ", ", @expected ); + + ok( my $response = request('http://localhost/action/chained/pathprefix/1'), + "PathPrefix (as an endpoint)" ); + is( $response->header('X-Catalyst-Executed'), + $expected, 'Executed actions' ); + is( $response->content, '; 1', 'Content OK' ); + } + + # + # static paths vs. captures + # + { + my @expected = qw[ + TestApp::Controller::Action::Chained->begin + TestApp::Controller::Action::Chained->apan + TestApp::Controller::Action::Chained->korv + TestApp::Controller::Action::Chained->static_end + TestApp::Controller::Action::Chained->end + ]; + + my $expected = join( ", ", @expected ); + + ok( my $response = request('http://localhost/action/chained/static_end'), + "static paths are prefered over captures" ); + is( $response->header('X-Catalyst-Executed'), + $expected, 'Executed actions' ); + } }