[Catalyst-commits] r10932 - in Catalyst-Runtime/5.80/branches/contextual_uri_for/t: . lib/TestApp/Controller

pjfl at dev.catalyst.perl.org pjfl at dev.catalyst.perl.org
Tue Jul 21 11:32:29 GMT 2009


Author: pjfl
Date: 2009-07-21 11:32:28 +0000 (Tue, 21 Jul 2009)
New Revision: 10932

Modified:
   Catalyst-Runtime/5.80/branches/contextual_uri_for/t/lib/TestApp/Controller/Root.pm
   Catalyst-Runtime/5.80/branches/contextual_uri_for/t/unit_core_contextual_uri_for.t
Log:
- Stop mangling config
- Added test for just one arg
- Better names for test actions

Modified: Catalyst-Runtime/5.80/branches/contextual_uri_for/t/lib/TestApp/Controller/Root.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/contextual_uri_for/t/lib/TestApp/Controller/Root.pm	2009-07-21 11:15:54 UTC (rev 10931)
+++ Catalyst-Runtime/5.80/branches/contextual_uri_for/t/lib/TestApp/Controller/Root.pm	2009-07-21 11:32:28 UTC (rev 10932)
@@ -21,8 +21,9 @@
 }
 
 # For contextual uri_for
-sub lang : Chained(/)    PathPart('') CaptureArgs(1) {}
-sub base : Chained(lang)              CaptureArgs(1) {}
-sub test : Chained(base) Args {}
+sub just_one_arg     : Chained(/) Args(1) {}
+sub leading_capture  : Chained(/) PathPart('') CaptureArgs(1) {}
+sub midpoint_capture : Chained(leading_capture) CaptureArgs(1) {}
+sub slurpy_endpoint  : Chained(midpoint_capture) Args {}
 
 1;

Modified: Catalyst-Runtime/5.80/branches/contextual_uri_for/t/unit_core_contextual_uri_for.t
===================================================================
--- Catalyst-Runtime/5.80/branches/contextual_uri_for/t/unit_core_contextual_uri_for.t	2009-07-21 11:15:54 UTC (rev 10931)
+++ Catalyst-Runtime/5.80/branches/contextual_uri_for/t/unit_core_contextual_uri_for.t	2009-07-21 11:32:28 UTC (rev 10932)
@@ -5,7 +5,7 @@
 use lib catdir( $Bin, q(lib) );
 
 use English qw( -no_match_vars );
-use Test::More tests => 10;
+use Test::More tests => 11;
 use URI;
 
 use_ok( q(TestApp) );
@@ -13,63 +13,55 @@
 my $request = Catalyst::Request->new( {
    base => URI->new( q(http://127.0.0.1) ) } );
 
-my $context = TestApp->new( { request => $request, namespace => '', } );
+my $context = TestApp->new( {
+   config    => { uri_for_defaults_to_action => 1,
+                  uri_for_default_action     => q(chain_root_index),
+                  uri_for_on_error           => q(die) },
+   request   => $request,
+   namespace => q(), } );
 
-# Well if it's not a plugin... where to put the config options?
-my $KEY = q(Plugin::ContextualUriFor);
-
-# If the first arg is false does we do a default action OR pass to core uri_for
-# I think this required as it is an either or case
-$context->config->{ $KEY }->{defaults_to_action} = 1;
-
-# I want the option to either die or log at a given level and return undef
-# This is fluff, should probably just do what core uri_for does on error
-$context->config->{ $KEY }->{on_error} = q(die);
-
-# The default method name is "default" but I want to override
-# Really need this one
-$context->config->{ $KEY }->{default_action} = q(chain_root_index);
-
-# This still has to work even if "defaults_to_action" is true
-is( $context->uri_for->as_string,
+is( $context->uri_for,
     q(http://127.0.0.1/),
     'URI for default action' );
 
-# This still has to work even if "defaults_to_action" is true
-is( $context->uri_for( q(), q(en) )->as_string,
+is( $context->uri_for( qw(root/just_one_arg a) ),
+    q(http://127.0.0.1/just_one_arg/a),
+    'URI for action with just one arg and no captures' );
+
+is( $context->uri_for( q(), q(en) ),
     q(http://127.0.0.1/en),
-    'URI for default action plus arg' );
+    'URI for default action plus leading capture arg' );
 
-is( $context->uri_for( q(root/test), qw(en a) ),
-    q(http://127.0.0.1/en/base/a/test),
-    'URI for test action' );
+is( $context->uri_for( qw(root/slurpy_endpoint en a) ),
+    q(http://127.0.0.1/en/midpoint_capture/a/slurpy_endpoint),
+    'URI for slurpy_endpoint no args or params' );
 
-is( $context->uri_for( q(root/test), qw(en a b) ),
-    q(http://127.0.0.1/en/base/a/test/b),
-    'URI for test action with some args' );
+is( $context->uri_for( qw(root/slurpy_endpoint en a b c) ),
+    q(http://127.0.0.1/en/midpoint_capture/a/slurpy_endpoint/b/c),
+    'URI for slurpy_endpoint with some args' );
 
-is( $context->uri_for( q(root/test), qw(en a b), { key1 => q(value1) } ),
-    q(http://127.0.0.1/en/base/a/test/b?key1=value1),
-    'URI for test action with some args and params' );
+is( $context->uri_for( qw(root/slurpy_endpoint en a b c), { key1 => q(value1) } ),
+    q(http://127.0.0.1/en/midpoint_capture/a/slurpy_endpoint/b/c?key1=value1),
+    'URI for slurpy_endpoint with some args and params' );
 
-is( $context->uri_for( qw(Root test), qw(en a b), { key1 => q(value1) } ),
-    q(http://127.0.0.1/en/base/a/test/b?key1=value1),
+is( $context->uri_for( qw(Root slurpy_endpoint en a b c) ),
+    q(http://127.0.0.1/en/midpoint_capture/a/slurpy_endpoint/b/c),
     'URI for controller and method' );
 
-is( $context->uri_for( qw(Root), undef, qw(en a b), { key1 => q(value1) } ),
-    q(http://127.0.0.1/en/a/b?key1=value1),
+is( $context->uri_for( q(Root), undef, qw(en a b c), { key1 => q(value1) } ),
+    q(http://127.0.0.1/en/a/b/c?key1=value1),
     'URI for controller and default method' );
 
-eval { $context->uri_for( q(root/base), q(en) ) };
+eval { $context->uri_for( qw(root/midpoint_capture en) ) };
 
 like( $EVAL_ERROR,
-      qr(\A Action \s base \s is \s a \s midpoint)msx,
+      qr(\A Action \s midpoint_capture \s is \s a \s midpoint)msx,
       'Midpoint detected' );
 
-eval { $context->uri_for( q(root/test), q(en) ) };
+eval { $context->uri_for( qw(root/slurpy_endpoint en) ) };
 
 like( $EVAL_ERROR,
-      qr(\A Action \s test \s insufficient \s args)msx,
+      qr(\A Action \s slurpy_endpoint \s insufficient \s args)msx,
       'Insufficient args' );
 
 # Local Variables:




More information about the Catalyst-commits mailing list