update for newer catalyst unicode changes
[catagits/Catalyst-View-TT.git] / t / utf8.t
CommitLineData
93c63aff 1use utf8;
2use warnings;
3use strict;
4use Test::More;
5use Encode 2.21 'decode_utf8', 'encode_utf8';
6use HTTP::Request::Common;
7use 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
35use Catalyst::Test 'MyApp';
36
37if(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
48done_testing;
49