stop using Moo as a test package
[catagits/Catalyst-Runtime.git] / t / aggregate / unit_core_uri_for_multibytechar.t
CommitLineData
93bd6d47 1use utf8;
0ce485e9 2use strict;
3use warnings;
0ce485e9 4use FindBin;
42da66a9 5use lib "$FindBin::Bin/../lib";
0ce485e9 6
6a887d55 7use Test::More;
0ce485e9 8
9use_ok('TestApp');
10
11my $base = 'http://127.0.0.1';
12
13my $request = Catalyst::Request->new({
7c1c4dc6 14 _log => Catalyst::Log->new,
0ce485e9 15 base => URI->new($base),
7066a4d5 16 uri => URI->new("$base/"),
0ce485e9 17});
18
19my $context = TestApp->new({
20 request => $request,
21});
22
23
24my $uri_with_multibyte = URI->new($base);
25$uri_with_multibyte->path('/');
26$uri_with_multibyte->query_form(
5afbe5de 27 name => '村瀬大輔',
0ce485e9 28);
29
0ce485e9 30# multibyte with utf8 bytes
7066a4d5 31is($context->uri_for('/', { name => '村瀬大輔' }), $uri_with_multibyte, 'uri_for with utf8 bytes query');
32is($context->req->uri_with({ name => '村瀬大輔' }), $uri_with_multibyte, 'uri_with with utf8 bytes query');
0ce485e9 33
34# multibyte with utf8 string
7066a4d5 35is($context->uri_for('/', { name => "\x{6751}\x{702c}\x{5927}\x{8f14}" }), $uri_with_multibyte, 'uri_for with utf8 string query');
36is($context->req->uri_with({ name => "\x{6751}\x{702c}\x{5927}\x{8f14}" }), $uri_with_multibyte, 'uri_with with utf8 string query');
6a887d55 37
38# multibyte captures and args
39my $action = $context->controller('Action::Chained')
40 ->action_for('roundtrip_urifor_end');
41
6a887d55 42is($context->uri_for($action, ['hütte'], 'hütte', {
43 test => 'hütte'
44}),
45'http://127.0.0.1/chained/roundtrip_urifor/h%C3%BCtte/h%C3%BCtte?test=h%C3%BCtte',
46'uri_for with utf8 captures and args');
93bd6d47 47
48is(
49 $context->uri_for($action, ['♥'], '♥', { '♥' => '♥'}),
50 'http://127.0.0.1/chained/roundtrip_urifor/' . '%E2%99%A5' . '/' . '%E2%99%A5' . '?' . '%E2%99%A5' . '=' . '%E2%99%A5',
51 'uri_for with utf8 captures and args');
52
53# ^ the match string is purposefully broken up to aid viewing, please to 'fix' it.
6a887d55 54
55done_testing;