10 if ( !eval { require Test::WWW::Mechanize::Catalyst; Test::WWW::Mechanize::Catalyst->VERSION('0.51') } ) {
11 plan skip_all => 'Need Test::WWW::Mechanize::Catalyst for this test';
15 # make sure testapp works
16 use_ok('TestAppUnicode') or BAIL_OUT($@);
18 # a live test against TestAppUnicode, the test application
19 use Test::WWW::Mechanize::Catalyst 'TestAppUnicode';
20 my $mech = Test::WWW::Mechanize::Catalyst->new;
21 $mech->get_ok('http://localhost/', 'get main page');
22 $mech->content_like(qr/it works/i, 'see if it has our text');
23 is ($mech->response->header('Content-Type'), 'text/html; charset=UTF-8',
24 'Content-Type with charset'
28 $mech->get_ok('http://localhost/unicode_no_enc', 'get unicode_no_enc');
30 my $exp = "\xE3\x81\xBB\xE3\x81\x92";
31 my $got = Encode::encode_utf8($mech->content);
33 is ($mech->response->header('Content-Type'), 'text/plain',
34 'Content-Type with no charset');
36 is($got, $exp, 'content contains hoge');
40 $mech->get_ok('http://localhost/unicode', 'get unicode');
42 is ($mech->response->header('Content-Type'), 'text/plain; charset=UTF-8',
43 'Content-Type with charset');
45 my $exp = "\xE3\x81\xBB\xE3\x81\x92";
46 my $got = Encode::encode_utf8($mech->content);
48 is($got, $exp, 'content contains hoge');
52 $mech->get_ok('http://localhost/not_unicode', 'get bytes');
53 my $exp = "\xE1\x88\xB4\xE5\x99\xB8";
54 my $got = Encode::encode_utf8($mech->content);
56 is($got, $exp, 'got 1234 5678');
60 $mech->get_ok('http://localhost/file', 'get file');
61 $mech->content_like(qr/this is a test/, 'got filehandle contents');
65 # The latin 1 case is the one everyone forgets. I want to really make sure
66 # its right, so lets check the damn bytes.
67 $mech->get_ok('http://localhost/latin1', 'get latin1');
68 is ($mech->response->header('Content-Type'), 'text/plain; charset=UTF-8',
69 'Content-Type with charset');
72 my $exp = "LATIN SMALL LETTER E WITH ACUTE: \xC3\xA9";
73 my $got = Encode::encode_utf8($mech->content);
75 is ($got, $exp, 'content octets are UTF-8');
79 $mech->get_ok('http://localhost/shift_jis', 'get shift_jis');
80 is ($mech->response->header('Content-Type'), 'text/plain; charset=Shift_JIS', 'Content-Type with charset');
81 my $exp = "\xE3\x81\xBB\xE3\x81\x92";
82 my $got = Encode::encode_utf8($mech->content);
83 is ($got, $exp, 'content octets are Shift_JIS');