X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=t%2Futf_incoming.t;h=096ba69cc1bc159a0843637d7aa88a7bcec5e636;hp=4a697ccab71ad094cd5c46e5dde6f5398c991981;hb=e5a5e80ba295da3a2f1fd8610b2f03299f9c5719;hpb=55f8e5163b1f5c502b92a9976350c611610c80e3 diff --git a/t/utf_incoming.t b/t/utf_incoming.t index 4a697cc..096ba69 100644 --- a/t/utf_incoming.t +++ b/t/utf_incoming.t @@ -25,12 +25,43 @@ use HTTP::Request::Common; $c->response->body("
This is path-hat action ^
"); } + sub uri_for :Path('uri_for') { + my ($self, $c) = @_; + $c->response->content_type('text/html'); + $c->response->body("${\$c->uri_for($c->controller('Root')->action_for('argend'), ['â¥'], 'â¥', {'â¥'=>'â¥â¥'})}"); + } + + sub heart_with_arg :Path('aâ¥') Args(1) { + my ($self, $c, $arg) = @_; + $c->response->content_type('text/html'); + $c->response->body("This is path-heart-arg action $arg
"); + Test::More::is $c->req->args->[0], 'â¥'; + } + sub base :Chained('/') CaptureArgs(0) { } sub link :Chained('base') PathPart('â¥') Args(0) { my ($self, $c) = @_; $c->response->content_type('text/html'); $c->response->body("This is base-link action â¥
"); } + sub arg :Chained('base') PathPart('â¥') Args(1) { + my ($self, $c, $arg) = @_; + $c->response->content_type('text/html'); + $c->response->body("This is base-link action ⥠$arg
"); + } + sub capture :Chained('base') PathPart('â¥') CaptureArgs(1) { + my ($self, $c, $arg) = @_; + $c->stash(capture=>$arg); + } + sub argend :Chained('capture') PathPart('â¥') Args(1) { + my ($self, $c, $arg) = @_; + $c->response->content_type('text/html'); + + Test::More::is $c->req->args->[0], 'â¥'; + Test::More::is $c->req->captures->[0], 'â¥'; + + $c->response->body("This is base-link action ⥠${\$c->req->args->[0]}
"); + } package MyApp; use Catalyst; @@ -54,6 +85,14 @@ use Encode 2.21 'decode_utf8', 'encode_utf8'; } { + my $res = request "/root/aâ¥/â¥"; + + is $res->code, 200, 'OK'; + is decode_utf8($res->content), 'This is path-heart-arg action â¥
', 'correct body'; + is $res->content_length, 40, 'correct length'; +} + +{ my $res = request "/root/^"; is $res->code, 200, 'OK'; @@ -79,16 +118,60 @@ use Encode 2.21 'decode_utf8', 'encode_utf8'; is $c->req->query_parameters->{'â¥'}[0], 'â¥'; is $c->req->body_parameters->{'â¥'}[0], 'â¥'; is $c->req->parameters->{'â¥'}[0], 'â¥'; - is $c->req->parameters->{a}, 1; is $c->req->body_parameters->{a}, 1; +} +{ + my ($res, $c) = ctx_request GET "/base/â¥?â¥â¥â¥"; + is $res->code, 200, 'OK'; + is decode_utf8($res->content), 'This is base-link action â¥
', 'correct body'; + is $res->content_length, 35, 'correct length'; + is $c->req->query_keywords, 'â¥â¥â¥'; } -## tests for args and captureargs (chained and otherise) -## warn $c->req->uri; (seemsto be pre encodinged and all -## test what uri_for looks like in responses +{ + my $res = request "/base/â¥/â¥"; + + is $res->code, 200, 'OK'; + is decode_utf8($res->content), 'This is base-link action ⥠â¥
', 'correct body'; + is $res->content_length, 39, 'correct length'; +} +{ + my $res = request "/base/â¥/â¥/â¥/â¥"; + + is $res->code, 200, 'OK'; + is decode_utf8($res->content), 'This is base-link action ⥠â¥
', 'correct body'; + is $res->content_length, 39, 'correct length'; +} + +{ + 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 = $c->req->uri; + + is "$uri", "$uri_for"; + + { + my ($res, $c) = ctx_request POST "$uri_for", [a=>1, b=>'2', 'â¥'=>'â¥â¥']; + is $c->req->query_parameters->{'â¥'}, 'â¥â¥'; + is $c->req->body_parameters->{'â¥'}, 'â¥â¥'; + is $c->req->parameters->{'â¥'}[0], 'â¥â¥'; #combined with query and body + } +} + +{ + my ($res, $c) = ctx_request "/root/uri_for"; + my $url = $c->uri_for($c->controller('Root')->action_for('argend'), ['â¥'], 'â¥', {'â¥'=>'â¥â¥'}); + + is $res->code, 200, 'OK'; + is decode_utf8($res->content), "$url", 'correct body'; #should do nothing + is $res->content, "$url", 'correct body'; + is $res->content_length, 90, 'correct length'; +} done_testing;