|
| 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( '[email protected]'); |
| 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( '[email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]', $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( '[email protected]', $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 | +} |
0 commit comments