X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Funit_core_uri_for_action.t;h=40861391acc8c6ef50cf616421ea5d4172180f98;hb=877c34d6f3c3deb465db9c7d2bb39de67366df97;hp=1d8b83930cb381dffd836292f2baeb2b13c882de;hpb=ad1783ae4aab4ce724e277cc09ed15a1ef1f64c6;p=catagits%2FCatalyst-Runtime.git diff --git a/t/unit_core_uri_for_action.t b/t/unit_core_uri_for_action.t index 1d8b839..4086139 100644 --- a/t/unit_core_uri_for_action.t +++ b/t/unit_core_uri_for_action.t @@ -8,7 +8,7 @@ use lib "$FindBin::Bin/lib"; use Test::More; -plan tests => 12; +plan tests => 17; use_ok('TestApp'); @@ -38,6 +38,9 @@ my $regex_action = $dispatcher->get_action_by_path( ok(!defined($dispatcher->uri_for_action($regex_action)), "Regex action without captures returns undef"); +ok(!defined($dispatcher->uri_for_action($regex_action, [ 1, 2, 3 ])), + "Regex action with too many captures returns undef"); + is($dispatcher->uri_for_action($regex_action, [ 'foo', 123 ]), "/action/regexp/foo/123", "Regex action interpolates captures correctly"); @@ -53,6 +56,20 @@ is($dispatcher->uri_for_action($index_action), "/action/index", "index action returns correct path"); +my $chained_action = $dispatcher->get_action_by_path( + '/action/chained/endpoint', + ); + +ok(!defined($dispatcher->uri_for_action($chained_action)), + "Chained action without captures returns undef"); + +ok(!defined($dispatcher->uri_for_action($chained_action, [ 1, 2 ])), + "Chained action with too many captures returns undef"); + +is($dispatcher->uri_for_action($chained_action, [ 1 ]), + "/chained/foo/1/end", + "Chained action with correct captures returns correct path"); + my $request = Catalyst::Request->new( { base => URI->new('http://127.0.0.1/foo') } ); @@ -76,3 +93,7 @@ ok(!defined($context->uri_for($path_action, [ 'blah' ])), is($context->uri_for($regex_action, [ 'foo', 123 ], qw/bar baz/, { q => 1 }), "http://127.0.0.1/foo/action/regexp/foo/123/bar/baz?q=1", "uri_for correct for regex with captures, args and query"); + +is($context->uri_for($chained_action, [ 1 ], 2, { q => 1 }), + "http://127.0.0.1/foo/chained/foo/1/end/2?q=1", + "uri_for correct for chained with captures, args and query");