fix up the unit_core_uri_for_multibytechar test; "use utf8" so that we actually test...
[catagits/Catalyst-Runtime.git] / t / unit_core_uri_for_multibytechar.t
CommitLineData
0ce485e9 1use strict;
2use warnings;
3
4use FindBin;
5use File::Spec;
6use lib File::Spec->catfile($FindBin::Bin, 'lib');
7
01d6806b 8use utf8; # for literal below
9use Encode; # URI.pm is braindead wrt unicode-flagged characters
0ce485e9 10
01d6806b 11use Test::More tests => 5;
0ce485e9 12
13use_ok('TestApp');
14
15my $base = 'http://127.0.0.1';
16
17my $request = Catalyst::Request->new({
18 base => URI->new($base),
7066a4d5 19 uri => URI->new("$base/"),
0ce485e9 20});
21
22my $context = TestApp->new({
23 request => $request,
24});
25
26
27my $uri_with_multibyte = URI->new($base);
28$uri_with_multibyte->path('/');
29$uri_with_multibyte->query_form(
01d6806b 30 name => Encode::encode('utf8', '村瀬大輔'),
0ce485e9 31);
32
0ce485e9 33# multibyte with utf8 bytes
7066a4d5 34is($context->uri_for('/', { name => '村瀬大輔' }), $uri_with_multibyte, 'uri_for with utf8 bytes query');
35is($context->req->uri_with({ name => '村瀬大輔' }), $uri_with_multibyte, 'uri_with with utf8 bytes query');
0ce485e9 36
37# multibyte with utf8 string
7066a4d5 38is($context->uri_for('/', { name => "\x{6751}\x{702c}\x{5927}\x{8f14}" }), $uri_with_multibyte, 'uri_for with utf8 string query');
39is($context->req->uri_with({ name => "\x{6751}\x{702c}\x{5927}\x{8f14}" }), $uri_with_multibyte, 'uri_with with utf8 string query');