6 # Test cases for incoming utf8
9 package MyApp::Controller::Root;
10 $INC{'MyApp/Controller/Root.pm'} = __FILE__;
12 use base 'Catalyst::Controller';
14 sub heart :Path('♥') {
16 $c->response->content_type('text/html');
17 $c->response->body("<p>This is path-heart action ♥</p>");
18 # We let the content length middleware find the length...
23 $c->response->content_type('text/html');
24 $c->response->body("<p>This is path-hat action ^</p>");
27 sub base :Chained('/') CaptureArgs(0) { }
28 sub link :Chained('base') PathPart('♥') Args(0) {
30 $c->response->content_type('text/html');
31 $c->response->body("<p>This is base-link action ♥</p>");
37 MyApp->config(encoding=>'UTF-8');
39 Test::More::ok(MyApp->setup, 'setup app');
42 ok my $psgi = MyApp->psgi_app, 'build psgi app';
44 use Catalyst::Test 'MyApp';
45 use Encode 2.21 'decode_utf8';
48 my $res = request "/root/♥";
50 is $res->code, 200, 'OK';
51 is decode_utf8($res->content), '<p>This is path-heart action ♥</p>', 'correct body';
52 is $res->content_length, 36, 'correct length';
56 my $res = request "/root/^";
58 is $res->code, 200, 'OK';
59 is decode_utf8($res->content), '<p>This is path-hat action ^</p>', 'correct body';
60 is $res->content_length, 32, 'correct length';
64 my $res = request "/base/♥";
66 is $res->code, 200, 'OK';
67 is decode_utf8($res->content), '<p>This is base-link action ♥</p>', 'correct body';
68 is $res->content_length, 35, 'correct length';
72 my $res = request "/base/♥?♥=♥♥";
74 is $res->code, 200, 'OK';
75 is decode_utf8($res->content), '<p>This is base-link action ♥</p>', 'correct body';
76 is $res->content_length, 35, 'correct length';