a few extra url generation tests
John Napiorkowski [Wed, 10 Dec 2014 00:25:26 +0000 (18:25 -0600)]
lib/Catalyst.pm
t/utf_incoming.t

index 92d5938..b595318 100644 (file)
@@ -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<URI> 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
index fef3553..04f724f 100644 (file)
@@ -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';
+  }
 }
 
 {