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=e9033919884e93f494990f9a429fe6e982d96e3a;hp=d51ba0f86ecec35baba96b3bd8708b5c668e8476;hb=f505df49a4707ce6962d8a9ebcf5280430a801cf;hpb=2349aeea36e187c7d285017b1a6f7dfb0695aa9b diff --git a/t/live_component_controller_action_chained.t b/t/live_component_controller_action_chained.t index d51ba0f..e903391 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} || 2; } -use Test::More tests => 96*$iters; +use Test::More tests => 106*$iters; use Catalyst::Test 'TestApp'; if ( $ENV{CAT_BENCHMARK} ) { @@ -19,11 +19,12 @@ if ( $ENV{CAT_BENCHMARK} ) { } else { for ( 1 .. $iters ) { - run_tests(); + run_tests($_); } } sub run_tests { + my ($run_number) = @_; # # This is a simple test where the parent and child actions are @@ -120,7 +121,7 @@ sub run_tests { # # The first three-chain test tries to call the action with :Args(1) - # specification. There's also a one action with a :Captures(1) + # specification. There's also a one action with a :CaptureArgs(1) # attribute, that should not be dispatched to. # { @@ -142,7 +143,7 @@ sub run_tests { # # This is the second three-chain test, it goes for the action that # handles "/one/$cap/two/$arg1/$arg2" paths. Should be the two action - # having :Args(2), not the one having :Captures(2). + # having :Args(2), not the one having :CaptureArgs(2). # { my @expected = qw[ @@ -162,9 +163,9 @@ sub run_tests { } # - # Last of the three-chain tests. Has no concurrent action with :Captures + # Last of the three-chain tests. Has no concurrent action with :CaptureArgs # and is more thought to simply test the chain as a whole and the 'two' - # action specifying :Captures. + # action specifying :CaptureArgs. # { my @expected = qw[ @@ -364,6 +365,27 @@ sub run_tests { } # + # This belongs to the former test but tests if two chained actions have + # priority over an action with one child action not having the Args() attr set. + # + { + my @expected = qw[ + TestApp::Controller::Action::Chained->begin + TestApp::Controller::Action::Chained->priority_c1 + TestApp::Controller::Action::Chained->priority_c2_xyz + TestApp::Controller::Action::Chained->end + ]; + + my $expected = join( ", ", @expected ); + + ok( my $response = request('http://localhost/chained/priority_c/1/xyz/'), + 'priority - no Args() order mismatch' ); + is( $response->header('X-Catalyst-Executed'), + $expected, 'Executed actions' ); + is( $response->content, '1; ', 'Content OK' ); + } + + # # Test dispatching between two controllers that are on the same level and # therefor have no parent/child relationship. # @@ -667,4 +689,63 @@ sub run_tests { $expected, 'Executed actions' ); is( $response->content, '1; 2', 'Content OK' ); } + + # + # Tests that an uri_for to a chained root index action + # returns the right value. + # + { + ok( my $response = request( + 'http://localhost/action/chained/to_root' ), + 'uri_for with chained root action as arg' ); + is( $response->content, + 'URI:http://localhost/', + 'Correct URI generated' ); + } + + # + # Test interception of recursive chains. This test was added because at + # one point during the :Chained development, Catalyst used to hang on + # recursive chains. + # + { + eval { require 'TestAppChainedRecursive.pm' }; + if ($run_number == 1) { + ok( ! $@, "Interception of recursive chains" ); + } + else { pass( "Interception of recursive chains already tested" ) } + } + + # + # Test failure of absolute path part arguments. + # + { + eval { require 'TestAppChainedAbsolutePathPart.pm' }; + if ($run_number == 1) { + like( $@, qr(foo/foo), + "Usage of absolute path part argument emits error" ); + } + else { pass( "Error on absolute path part arguments already tested" ) } + } + + # + # Complex path with multiple empty pathparts + # + { + my @expected = qw[ + TestApp::Controller::Action::Chained->begin + TestApp::Controller::Action::Chained->mult_nopp_base + TestApp::Controller::Action::Chained->mult_nopp_all + TestApp::Controller::Action::Chained->end + ]; + + my $expected = join( ", ", @expected ); + + ok( my $response = request('http://localhost/chained/mult_nopp'), + "Complex path with multiple empty pathparts" ); + is( $response->header('X-Catalyst-Executed'), + $expected, 'Executed actions' ); + is( $response->content, '; ', 'Content OK' ); + } + }