make this work with cat 5.90080+
[catagits/Test-WWW-Mechanize-Catalyst.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 lib 't/lib';
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->response->content_type('text/html');
17     $c->response->body("<p>This is path-heart action ♥</p>");
18   }
19
20   package MyApp;
21   use Catalyst;
22
23   MyApp->setup;
24 }
25
26 use Test::WWW::Mechanize::Catalyst 'MyApp';
27
28 my $root = "http://localhost";
29 my $m = Test::WWW::Mechanize::Catalyst->new( autocheck => 0 );
30
31 if(MyApp->can('encoding') and MyApp->can('clear_encoding') and MyApp->encoding eq 'UTF-8') {
32   $m->get_ok("$root/root/♥", 'got page');
33   is( $m->ct, "text/html" );
34   $m->content_contains("This is path-heart action ♥", 'matched expected content');
35 } else {
36   ok 1, 'Skipping the UTF8 Tests for older installed catalyst';
37 }
38
39 done_testing;
40