From: John Napiorkowski Date: Wed, 10 Dec 2014 00:25:26 +0000 (-0600) Subject: a few extra url generation tests X-Git-Tag: 5.90079_008~26 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=b063a165c4247e0312f19ed90829a0e7161fa449 a few extra url generation tests --- diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 92d5938..b595318 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -1335,6 +1335,8 @@ sub setup_finalize { =head2 $c->uri_for( $action, \@captures?, @args?, \%query_values? ) +=head2 $c->uri_for( $action, [@captures, @args], \%query_values? ) + Constructs an absolute L object based on the application root, the provided path, and the additional arguments and query parameters provided. When used as a string, provides a textual URI. If you need more flexibility diff --git a/t/utf_incoming.t b/t/utf_incoming.t index fef3553..04f724f 100644 --- a/t/utf_incoming.t +++ b/t/utf_incoming.t @@ -202,13 +202,15 @@ use Catalyst::Test 'MyApp'; my ($res, $c) = ctx_request POST "/base/♥/♥/♥/♥?♥=♥♥", [a=>1, b=>'2', '♥'=>'♥♥']; ## Make sure that the urls we generate work the same - my $uri_for = $c->uri_for($c->controller('Root')->action_for('argend'), ['♥'], '♥', {'♥'=>'♥♥'}); + my $uri_for1 = $c->uri_for($c->controller('Root')->action_for('argend'), ['♥'], '♥', {'♥'=>'♥♥'}); + my $uri_for2 = $c->uri_for($c->controller('Root')->action_for('argend'), ['♥', '♥'], {'♥'=>'♥♥'}); my $uri = $c->req->uri; - is "$uri", "$uri_for"; + is "$uri_for1", "$uri_for2"; + is "$uri", "$uri_for1"; { - my ($res, $c) = ctx_request POST "$uri_for", [a=>1, b=>'2', '♥'=>'♥♥']; + my ($res, $c) = ctx_request POST "$uri_for1", [a=>1, b=>'2', '♥'=>'♥♥']; is $c->req->query_parameters->{'♥'}, '♥♥'; is $c->req->body_parameters->{'♥'}, '♥♥'; is $c->req->parameters->{'♥'}[0], '♥♥'; #combined with query and body @@ -225,6 +227,16 @@ use Catalyst::Test 'MyApp'; is $res->content, "$url", 'correct body'; is $res->content_length, 90, 'correct length'; is $res->content_charset, 'UTF-8'; + + { + my $url = $c->uri_for($c->controller->action_for('heart_with_arg'), '♥'); + is "$url", 'http://localhost/root/a%E2%99%A5/%E2%99%A5'; + } + + { + my $url = $c->uri_for($c->controller->action_for('heart_with_arg'), ['♥']); + is "$url", 'http://localhost/root/a%E2%99%A5/%E2%99%A5'; + } } {