Commit | Line | Data |
93c63aff |
1 | use utf8; |
2 | use warnings; |
3 | use strict; |
4 | use Test::More; |
5 | use Encode 2.21 'decode_utf8', 'encode_utf8'; |
6 | use HTTP::Request::Common; |
7 | use File::Spec; |
8 | |
9 | { |
10 | package MyApp::Controller::Root; |
11 | $INC{'MyApp/Controller/Root.pm'} = __FILE__; |
12 | |
13 | use base 'Catalyst::Controller'; |
14 | |
15 | sub heart :Path('♥') { |
16 | my ($self, $c) = @_; |
17 | $c->stash(hearts=>'♥♥♥'); |
18 | $c->detach('View::HTML'); |
19 | } |
20 | package MyApp::View::HTML; |
21 | $INC{'MyApp/View/HTML.pm'} = __FILE__; |
22 | |
23 | use base 'Catalyst::View::TT'; |
24 | |
25 | MyApp::View::HTML->config( |
26 | ENCODING => 'UTF-8', |
27 | INCLUDE_PATH=> File::Spec->catfile('t')); |
28 | |
29 | package MyApp; |
30 | use Catalyst; |
31 | |
32 | MyApp->setup; |
33 | } |
34 | |
35 | use Catalyst::Test 'MyApp'; |
36 | |
37 | if(MyApp->can('encoding') and MyApp->can('clear_encoding') ) { |
38 | ok my $res = request GET '/root/♥', 'Accept-Encoding' => 'gzip'; |
39 | |
40 | is $res->code, 200, 'OK'; |
41 | |
42 | is decode_utf8($res->content), "<p>This heart literal ♥</p><p>This is heart var ♥♥♥</p>\n", 'correct body'; |
43 | is $res->content_charset, 'UTF-8'; |
44 | } else { |
45 | ok 1, 'Skipping the UTF8 Tests for older installed catalyst'; |
46 | } |
47 | |
48 | done_testing; |
49 | |