minor test cleanup
[catagits/Catalyst-View-TT.git] / t / utf8.t
1 use utf8;
2 use warnings;
3 use strict;
4 use Test::More;
5 use Encode 2.21 'decode_utf8', 'encode_utf8';
6 use 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
34 use Catalyst::Test 'MyApp';
35
36 if(MyApp->can('encoding') and MyApp->can('clear_encoding') ) {
37   ok my $res = request '/root/♥';
38   is $res->code, 200, 'OK';
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
45 done_testing;
46