TODO tests added for :ChainedParent and :Chained('../action') atrs
Ash Berlin [Fri, 1 Aug 2008 16:58:25 +0000 (16:58 +0000)]
t/lib/TestApp/Controller/Action/Chained/ParentChain.pm
t/live_component_controller_action_chained.t

index ec72a38..fd9d9e7 100644 (file)
@@ -10,4 +10,16 @@ use base qw/ Catalyst::Controller /;
 #
 sub child :Chained('.') :Args(1) { }
 
+# Should be at /chained/rootdef/*/chained_rel
+sub chained_rel :Chained('../rootdef') Args(0) {
+}
+
+# Should chain to loose in parent namespace - i.e. at /chained/loose/*/loose/*/*
+sub loose : ChainedParent Args(2) {
+}
+
+# Should be at /chained/cross/*/up_down/*
+sub up_down : Chained('../bar/cross1') Args(1) {
+}
+
 1;
index 9cb6bf4..d2bf107 100644 (file)
@@ -10,7 +10,7 @@ our $iters;
 
 BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; }
 
-use Test::More tests => 127*$iters;
+use Test::More tests => 136*$iters;
 use Catalyst::Test 'TestApp';
 
 if ( $ENV{CAT_BENCHMARK} ) {
@@ -528,6 +528,69 @@ sub run_tests {
     }
 
     #
+    #   Test if :Chained('../act') is working
+    #
+    {
+        local $TODO = "To Be Coded";
+        my @expected = qw[
+          TestApp::Controller::Action::Chained->begin
+          TestApp::Controller::Action::Chained->rootdef
+          TestApp::Controller::Action::Chained::ParentChain->chained_rel
+          TestApp::Controller::Action::Chained->end
+        ];
+
+        my $expected = join( ", ", @expected );
+
+        ok( my $response = request('http://localhost/chained/rootdef/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 :ChainedParent is working
+    #
+    {
+        local $TODO = "To Be Coded";
+        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
+    #
+    {
+        local $TODO = "To Be Coded";
+        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.
     #
     {