more utf8 tests and fixes
[catagits/Catalyst-Runtime.git] / t / lib / TestAppEncoding / Controller / Root.pm
CommitLineData
5ab21903 1package TestAppEncoding::Controller::Root;
2use strict;
3use warnings;
4use base 'Catalyst::Controller';
5use Test::More;
6
7__PACKAGE__->config->{namespace} = '';
8
9sub binary : Local {
10 my ($self, $c) = @_;
4a64c27b 11 $c->res->content_type('image/gif');
b9b257cc 12 $c->res->body(do {
a8946dc8 13 open(my $fh, '<', $c->path_to('..', '..', 'catalyst_130pix.gif')) or die $!;
efcb1ae7 14 binmode($fh);
15 local $/ = undef; <$fh>;
16 });
5ab21903 17}
18
19sub binary_utf8 : Local {
20 my ($self, $c) = @_;
21 $c->forward('binary');
22 my $str = $c->res->body;
23 utf8::upgrade($str);
24 ok utf8::is_utf8($str), 'Body is variable width encoded string';
25 $c->res->body($str);
26}
27
d9669e44 28# called by t/aggregate/catalyst_test_utf8.t
29sub utf8_non_ascii_content : Local {
30 use utf8;
31 my ($self, $c) = @_;
32
33 my $str = 'ʇsʎlɐʇɐɔ'; # 'catalyst' flipped at http://www.revfad.com/flip.html
34 ok utf8::is_utf8($str), '$str is in UTF8 internally';
4a64c27b 35
36 $c->res->content_type('text/plain');
d9669e44 37 $c->res->body($str);
38}
39
40
5ab21903 41sub end : Private {
42 my ($self,$c) = @_;
43}
44
451;