summaryrefslogtreecommitdiff
path: root/rt/t/api/i18n_mime_encoding.t
blob: 5ad532ed2967e0a05bb04bf5fc0c4b2d0e3edcbe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use warnings;
use strict;

use RT::Test nodata => 1, tests => undef;
use RT::I18N;
use Test::Warn;

diag "normal mime encoding conversion: utf8 => iso-8859-1";
{
    my $mime = MIME::Entity->build(
        Type => 'text/plain; charset=utf-8',
        Data => ['À中文'],
    );

    warning_like {
        RT::I18N::SetMIMEEntityToEncoding( $mime, 'iso-8859-1', );
    }
    [ qr/does not map to iso-8859-1/ ], 'got one "not map" error';
    is( $mime->stringify_body, 'À中文', 'body is not changed' );
    is( $mime->head->mime_attr('Content-Type'), 'application/octet-stream' );
}

diag "mime encoding conversion: utf8 => iso-8859-1";
{
    my $mime = MIME::Entity->build(
        Type => 'text/plain; charset=utf-8',
        Data => ['À中文'],
    );
    is( $mime->stringify_body, 'À中文', 'body is not changed' );
}

done_testing;