5 use RT::Test tests => 7;
10 ok (require RT::Attachment);
17 my $test1 = "From: jesse";
18 my @headers = RT::Attachment->_SplitHeaders($test1);
19 is ($#headers, 0, $test1 );
21 my $test2 = qq{From: jesse
26 @headers = RT::Attachment->_SplitHeaders($test2);
27 is ($#headers, 2, "testing a bunch of singline multiple headers" );
30 my $test3 = qq{From: jesse
38 @headers = RT::Attachment->_SplitHeaders($test3);
39 is ($#headers, 2, "testing a bunch of singline multiple headers" );
47 my $iso_8859_1_ticket_email =
48 RT::Test::get_relocatable_file( 'new-ticket-from-iso-8859-1',
49 ( File::Spec->updir(), 'data', 'emails' ) );
50 my $content = RT::Test->file_content($iso_8859_1_ticket_email);
52 my $parser = RT::EmailParser->new;
53 $parser->ParseMIMEEntityFromScalar($content);
54 my $attachment = RT::Attachment->new( $RT::SystemUser );
56 $attachment->Create( TransactionId => 1, Attachment => $parser->Entity );
58 my $mime = $attachment->ContentAsMIME;
59 like( $mime->head->get('Content-Type'),
60 qr/charset="iso-8859-1"/, 'content type of ContentAsMIME is original' );
63 Encode::decode( 'iso-8859-1', $mime->stringify_body ),
64 Encode::decode( 'utf8', "HÃ¥vard\n" ),
65 'body of ContentAsMIME is original'