Moved Chained intro to dispatch type and made recursion test more sane.
[catagits/Catalyst-Runtime.git] / t / live_component_controller_action_chained.t
index dca2385..a92f32c 100644 (file)
@@ -10,7 +10,7 @@ our $iters;
 
 BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 2; }
 
-use Test::More tests => 96*$iters;
+use Test::More tests => 101*$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
@@ -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,29 @@ sub run_tests {
             $expected, 'Executed actions' );
         is( $response->content, '1; 2', 'Content OK' );
     }
+
+    #
+    #   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" ) }
+    }
 }