import rt 3.8.11
[freeside.git] / rt / t / mail / wrong_mime_charset.t
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4 use RT::Test nodata => 1, tests => 3;
5
6 use_ok('RT::I18N');
7 use utf8;
8 use Encode;
9 my $test_string    = 'À';
10 my $encoded_string = encode( 'iso-8859-1', $test_string );
11 my $mime           = MIME::Entity->build(
12     "Subject" => $encoded_string,
13     "Data"    => [$encoded_string],
14 );
15
16 # set the wrong charset mime in purpose
17 $mime->head->mime_attr( "Content-Type.charset" => 'utf8' );
18
19 RT::I18N::SetMIMEEntityToEncoding( $mime, 'iso-8859-1' );
20
21 TODO: {
22         local $TODO =
23 'need a better approach of encoding converter, should be fixed in 4.2';
24
25 my $subject = decode( 'iso-8859-1', $mime->head->get('Subject') );
26 chomp $subject;
27 is( $subject, $test_string, 'subject is set to iso-8859-1' );
28 my $body = decode( 'iso-8859-1', $mime->stringify_body );
29 chomp $body;
30 is( $body, $test_string, 'body is set to iso-8859-1' );
31 }