Commit | Line | Data |
93bd6d47 |
1 | use utf8; |
0ce485e9 |
2 | use strict; |
3 | use warnings; |
0ce485e9 |
4 | use FindBin; |
42da66a9 |
5 | use lib "$FindBin::Bin/../lib"; |
0ce485e9 |
6 | |
6a887d55 |
7 | use Test::More; |
0ce485e9 |
8 | |
9 | use_ok('TestApp'); |
10 | |
11 | my $base = 'http://127.0.0.1'; |
12 | |
13 | my $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 | |
19 | my $context = TestApp->new({ |
20 | request => $request, |
21 | }); |
22 | |
23 | |
24 | my $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 |
31 | is($context->uri_for('/', { name => '村瀬大輔' }), $uri_with_multibyte, 'uri_for with utf8 bytes query'); |
32 | is($context->req->uri_with({ name => '村瀬大輔' }), $uri_with_multibyte, 'uri_with with utf8 bytes query'); |
0ce485e9 |
33 | |
34 | # multibyte with utf8 string |
7066a4d5 |
35 | is($context->uri_for('/', { name => "\x{6751}\x{702c}\x{5927}\x{8f14}" }), $uri_with_multibyte, 'uri_for with utf8 string query'); |
36 | is($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 |
39 | my $action = $context->controller('Action::Chained') |
40 | ->action_for('roundtrip_urifor_end'); |
41 | |
6a887d55 |
42 | is($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 | |
48 | is( |
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 | |
55 | done_testing; |