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