File: i18n_mime_encoding.t

package info (click to toggle)
request-tracker5 5.0.3%2Bdfsg-3~deb12u3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 77,648 kB
  • sloc: javascript: 187,930; perl: 79,061; sh: 1,302; makefile: 471; python: 37; php: 15
file content (32 lines) | stat: -rw-r--r-- 847 bytes parent folder | download | duplicates (10)
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;