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