Skip to content

Commit cb17869

Browse files
committed
Test rendering of attached message/rfc822 parts
1 parent 06f14f5 commit cb17869

File tree

2 files changed

+123
-0
lines changed

2 files changed

+123
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
namespace Tests\MessageRendering;
4+
5+
/**
6+
* Test class to test simple messages.
7+
*/
8+
class MessageRfc822Test extends MessageRenderingTestCase
9+
{
10+
public function testRfc822Part()
11+
{
12+
$domxpath = $this->runAndGetHtmlOutputDomxpath('4052c2097de93825c1be040270d98e47@example.net');
13+
$this->assertSame('Fwd: Lines', $this->getScrubbedSubject($domxpath));
14+
15+
$parts = $domxpath->query('//div[@id="messagebody"]/div');
16+
$this->assertCount(3, $parts);
17+
$this->assertSame('message-part', $parts[0]->attributes->getNamedItem('class')->textContent);
18+
$this->assertSame('Check the forwarded message', $parts[0]->textContent);
19+
$this->assertSame('message-part', $parts[2]->attributes->getNamedItem('class')->textContent);
20+
$this->assertStringStartsWith('Plain text message body.', $parts[2]->textContent);
21+
22+
$this->assertSame('message-partheaders', $parts[1]->attributes->getNamedItem('class')->textContent);
23+
24+
$msgRfc822Subject = $domxpath->query('//div[@class="message-partheaders"]//td[@class="header subject"]');
25+
$this->assertCount(1, $msgRfc822Subject);
26+
$this->assertSame('Lines', $msgRfc822Subject[0]->textContent);
27+
28+
$msgRfc822From = $domxpath->query('//div[@class="message-partheaders"]//td[@class="header from"]');
29+
$this->assertCount(1, $msgRfc822From);
30+
$this->assertSame('Thomas B.', $msgRfc822From[0]->textContent);
31+
32+
$msgRfc822To = $domxpath->query('//div[@class="message-partheaders"]//td[@class="header to"]');
33+
$this->assertCount(1, $msgRfc822To);
34+
$this->assertSame('Tom Tester', $msgRfc822To[0]->textContent);
35+
36+
$msgRfc822Cc = $domxpath->query('//div[@class="message-partheaders"]//td[@class="header cc"]');
37+
$this->assertCount(1, $msgRfc822Cc);
38+
$this->assertSame('test1@domain.tld, test2@domain.tld, test3@domain.tld, test4@domain.tld, test5@domain.tld, test6@domain.tld, test7@domain.tld, test8@domain.tld, test9@domain.tld, test10@domain.tld, test11@domain.tld, test12@domain.tld', $msgRfc822Cc[0]->textContent);
39+
40+
$msgRfc822ReplyTo = $domxpath->query('//div[@class="message-partheaders"]//td[@class="header mail-reply-to"]');
41+
$this->assertCount(1, $msgRfc822ReplyTo);
42+
$this->assertSame('hello@roundcube.net', $msgRfc822ReplyTo[0]->textContent);
43+
44+
$msgRfc822Date = $domxpath->query('//div[@class="message-partheaders"]//td[@class="header date"]');
45+
$this->assertCount(1, $msgRfc822Date);
46+
// Using a RegExp here, because the result is different depending on the timezone of the testing environment.
47+
$this->assertMatchesRegularExpression('/2014-05-2[234]{1} \d{2}:\d{2}/', $msgRfc822Date[0]->textContent);
48+
}
49+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
MIME-Version: 1.0
2+
Date: Wed, 15 Jan 2025 11:44:00 +0100
3+
From: admin@example.net
4+
To: admin@example.net
5+
Subject: Fwd: Lines
6+
In-Reply-To: <99839b8ec12482419372f1edafa9de75@woodcrest.local>
7+
References: <99839b8ec12482419372f1edafa9de75@woodcrest.local>
8+
Message-ID: <4052c2097de93825c1be040270d98e47@example.net>
9+
X-Sender: admin@example.net
10+
X-Draft-Info: type=forward; uid=3; folder=B::SU5CT1g=
11+
Content-Type: multipart/mixed;
12+
boundary="=_9b038d50a3b2b5cfe9fdbd53743b1ea9"
13+
14+
--=_9b038d50a3b2b5cfe9fdbd53743b1ea9
15+
Content-Transfer-Encoding: 7bit
16+
Content-Type: text/plain; charset=US-ASCII;
17+
format=flowed
18+
19+
Check the forwarded message
20+
--=_9b038d50a3b2b5cfe9fdbd53743b1ea9
21+
Content-Transfer-Encoding: 8bit
22+
Content-Type: message/rfc822;
23+
name=Lines.eml
24+
Content-Disposition: attachment;
25+
filename=Lines.eml;
26+
size=1382
27+
28+
Return-Path: <thomas@roundcube.net>
29+
X-Original-To: tb@tester.local
30+
From: "Thomas B." <thomas@roundcube.net>
31+
To: Tom Tester <tb@tester.local>
32+
Subject: Lines
33+
Cc: test1@domain.tld, test2@domain.tld, test3@domain.tld, test4@domain.tld,
34+
test5@domain.tld, test6@domain.tld, test7@domain.tld, test8@domain.tld,
35+
test9@domain.tld, test10@domain.tld, test11@domain.tld, test12@domain.tld
36+
MIME-Version: 1.0
37+
Content-Type: multipart/mixed;
38+
boundary="=_8853bfb47b7da1852ac882e69cc724f3"
39+
Date: Fri, 23 May 2014 19:44:50 +0200
40+
Reply-To: hello@roundcube.net
41+
Mail-Reply-To: hello@roundcube.net
42+
Message-ID: <99839b8ec12482419372f1edafa9de75@woodcrest.local>
43+
X-Sender: thomas@roundcube.net
44+
45+
--=_8853bfb47b7da1852ac882e69cc724f3
46+
Content-Transfer-Encoding: 7bit
47+
Content-Type: text/plain; charset=UTF-8;
48+
format=flowed
49+
50+
Plain text message body.
51+
52+
--
53+
Developer of Free Software
54+
Sent with Roundcube Webmail - roundcube.net
55+
--=_8853bfb47b7da1852ac882e69cc724f3
56+
Content-Transfer-Encoding: base64
57+
Content-Type: text/plain;
58+
name=lines.txt
59+
Content-Disposition: attachment;
60+
filename=lines.txt;
61+
size=13
62+
63+
Zm9vDQpiYXINCmduYQ==
64+
--=_8853bfb47b7da1852ac882e69cc724f3
65+
Content-Transfer-Encoding: base64
66+
Content-Type: text/plain;
67+
name=lines_lf.txt
68+
Content-Disposition: attachment;
69+
filename=lines_lf.txt;
70+
size=11
71+
72+
Zm9vCmJhcgpnbmE=
73+
--=_8853bfb47b7da1852ac882e69cc724f3--
74+
--=_9b038d50a3b2b5cfe9fdbd53743b1ea9--

0 commit comments

Comments
 (0)