make this work with cat 5.90080+
[catagits/Test-WWW-Mechanize-Catalyst.git] / t / lib / Catty / Controller / Root.pm
index 4d74605..735b1d0 100644 (file)
@@ -2,12 +2,12 @@ package Catty::Controller::Root;
 
 use strict;
 use warnings;
-
 use base qw/ Catalyst::Controller /;
 
 use Cwd;
 use MIME::Base64;
 use Encode ();
+use utf8;
 
 __PACKAGE__->config( namespace => '' );
 
@@ -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
@@ -121,7 +125,7 @@ sub gzipped : Global {
   # control both ends, so just always gzip the response.
     require Compress::Zlib;
 
-    my $html = html( "Hello", "Hi there! ☺" );
+    my $html = Encode::encode('UTF-8', html( "Hello", "Hi there! ☺" ));
     $c->response->content_type("text/html; charset=utf-8");
     $c->response->output( Compress::Zlib::memGzip($html) );
     $c->response->content_encoding('gzip');
@@ -144,5 +148,12 @@ sub bad_content_encoding :Global {
     $c->res->body('foo');
 }
 
+sub redirect_to_utf8_upgraded_string : Global {
+    my($self, $c) = @_;
+    my $where = $c->uri_for('hello', 'müller')->as_string;
+    utf8::upgrade($where);
+    $c->res->redirect($where);
+}
+
 1;