[Catalyst-commits] r10935 - in
Catalyst-Runtime/5.80/branches/contextual_uri_for/t: .
lib/TestApp/Controller lib/TestApp/Controller/Chained
pjfl at dev.catalyst.perl.org
pjfl at dev.catalyst.perl.org
Tue Jul 21 14:43:59 GMT 2009
Author: pjfl
Date: 2009-07-21 14:43:58 +0000 (Tue, 21 Jul 2009)
New Revision: 10935
Added:
Catalyst-Runtime/5.80/branches/contextual_uri_for/t/lib/TestApp/Controller/Chained/
Catalyst-Runtime/5.80/branches/contextual_uri_for/t/lib/TestApp/Controller/Chained/ContextualUriFor.pm
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:
Added: Catalyst-Runtime/5.80/branches/contextual_uri_for/t/lib/TestApp/Controller/Chained/ContextualUriFor.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/contextual_uri_for/t/lib/TestApp/Controller/Chained/ContextualUriFor.pm (rev 0)
+++ Catalyst-Runtime/5.80/branches/contextual_uri_for/t/lib/TestApp/Controller/Chained/ContextualUriFor.pm 2009-07-21 14:43:58 UTC (rev 10935)
@@ -0,0 +1,14 @@
+package TestApp::Controller::Chained::ContextualUriFor;
+
+use parent q(Catalyst::Controller);
+
+__PACKAGE__->config->{namespace} = q();
+
+sub base : Chained(/) PathPart('') CaptureArgs(0) {}
+sub default_endpoint : Chained(base) PathPart('') Args(0) {}
+sub just_one_arg : Chained(base) Args(1) {}
+sub leading_capture : Chained(base) 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/lib/TestApp/Controller/Root.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/contextual_uri_for/t/lib/TestApp/Controller/Root.pm 2009-07-21 12:38:27 UTC (rev 10934)
+++ Catalyst-Runtime/5.80/branches/contextual_uri_for/t/lib/TestApp/Controller/Root.pm 2009-07-21 14:43:58 UTC (rev 10935)
@@ -20,10 +20,4 @@
$c->forward('TestApp::View::Dump::Request');
}
-# For contextual uri_for
-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 12:38:27 UTC (rev 10934)
+++ Catalyst-Runtime/5.80/branches/contextual_uri_for/t/unit_core_contextual_uri_for.t 2009-07-21 14:43:58 UTC (rev 10935)
@@ -5,7 +5,7 @@
use lib catdir( $Bin, q(lib) );
use English qw( -no_match_vars );
-use Test::More tests => 11;
+use Test::More tests => 13;
use URI;
use_ok( q(TestApp) );
@@ -14,24 +14,31 @@
base => URI->new( q(http://127.0.0.1) ) } );
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(), } );
+ config => { uri_for_defaults_to_action => 1,
+ uri_for_default_action => q(default_endpoint),
+ uri_for_on_error => q(die) },
+ request => $request } );
is( $context->uri_for,
q(http://127.0.0.1/),
- 'URI for default action' );
+ 'URI for default private path with no args at all' );
+is( $context->uri_for( q(), q(en) ),
+ q(http://127.0.0.1/en),
+ 'URI for default private path plus leading capture arg' );
+
+is( $context->uri_for( qw(root) ),
+ q(http://127.0.0.1/),
+ 'URI for private path with default action name and no args at all' );
+
+is( $context->uri_for( qw(/just_one_arg a) ),
+ q(http://127.0.0.1/just_one_arg/a),
+ 'URI for private path with default namespace' );
+
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' );
+ 'URI for private path 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 leading capture arg' );
-
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' );
@@ -44,12 +51,12 @@
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 slurpy_endpoint en a b c) ),
+is( $context->uri_for( qw(Chained::ContextualUriFor 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( q(Root), undef, qw(en a b c), { key1 => q(value1) } ),
- q(http://127.0.0.1/en/a/b/c?key1=value1),
+is( $context->uri_for( q(Chained::ContextualUriFor) ),
+ q(http://127.0.0.1/),
'URI for controller and default method' );
eval { $context->uri_for( qw(root/midpoint_capture en) ) };
More information about the Catalyst-commits
mailing list