From: John Napiorkowski Date: Fri, 26 Dec 2014 21:30:29 +0000 (-0600) Subject: make this work with cat 5.90080+ X-Git-Tag: 0.60~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FTest-WWW-Mechanize-Catalyst.git;a=commitdiff_plain;h=4c96289cce33e758321f14dfc7ca35d3ebfa3fa4 make this work with cat 5.90080+ --- diff --git a/t/lib/Catty/Controller/Root.pm b/t/lib/Catty/Controller/Root.pm index 17498fd..735b1d0 100644 --- a/t/lib/Catty/Controller/Root.pm +++ b/t/lib/Catty/Controller/Root.pm @@ -24,6 +24,10 @@ sub hello : Global { my $html = html( "Hello", "Hi there! $str" ); $context->response->content_type("text/html; charset=utf-8"); $context->response->output($html); + + # Newer Catalyst auto encodes UTF8, but this test case is borked and expects + # broken utf8 behavior. We'll make a real UTF8 Test case separately. + $context->clear_encoding if $context->can('clear_encoding'); # Compat with upcoming Catalyst 5.90080 } # absolute redirect diff --git a/t/lib/ExternalCatty/Controller/Root.pm b/t/lib/ExternalCatty/Controller/Root.pm index 0409a7a..83696fe 100644 --- a/t/lib/ExternalCatty/Controller/Root.pm +++ b/t/lib/ExternalCatty/Controller/Root.pm @@ -10,6 +10,10 @@ sub default : Private { my ( $self, $c ) = @_; $c->response->content_type('text/html; charset=utf-8'); $c->response->output( html( 'Root', 'Hello, test ☺!' ) ); + + # Newer Catalyst auto encodes UTF8, but this test case is borked and expects + # broken utf8 behavior. We'll make a real UTF8 Test case separately. + $c->clear_encoding if $c->can('clear_encoding'); # Compat with upcoming Catalyst 5.90080 } # redirect to a redirect diff --git a/t/utf8.t b/t/utf8.t new file mode 100644 index 0000000..08ddd2c --- /dev/null +++ b/t/utf8.t @@ -0,0 +1,40 @@ +use utf8; +use warnings; +use strict; +use Test::More; +use Encode 2.21 'decode_utf8', 'encode_utf8'; +use lib 't/lib'; + +{ + package MyApp::Controller::Root; + $INC{'MyApp/Controller/Root.pm'} = __FILE__; + + use base 'Catalyst::Controller'; + + sub heart :Path('♥') { + my ($self, $c) = @_; + $c->response->content_type('text/html'); + $c->response->body("

This is path-heart action ♥

"); + } + + package MyApp; + use Catalyst; + + MyApp->setup; +} + +use Test::WWW::Mechanize::Catalyst 'MyApp'; + +my $root = "http://localhost"; +my $m = Test::WWW::Mechanize::Catalyst->new( autocheck => 0 ); + +if(MyApp->can('encoding') and MyApp->can('clear_encoding') and MyApp->encoding eq 'UTF-8') { + $m->get_ok("$root/root/♥", 'got page'); + is( $m->ct, "text/html" ); + $m->content_contains("This is path-heart action ♥", 'matched expected content'); +} else { + ok 1, 'Skipping the UTF8 Tests for older installed catalyst'; +} + +done_testing; +