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