RoundCube Webmail
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
3.0 KiB

  1. <?php
  2. namespace Tests\MessageRendering;
  3. /**
  4. * Test class to test simple messages.
  5. */
  6. class MarkdownTest extends MessageRenderingTestCase
  7. {
  8. public function testMarkdownContent()
  9. {
  10. $domxpath = $this->runAndGetHtmlOutputDomxpath('e40d23f5d4b928f1536699b0723fa4a84ef3467d76ecbcdc361e8c394c6675a3@example.net');
  11. $this->assertSame('Markdown', $this->getScrubbedSubject($domxpath));
  12. $msgParts = $domxpath->query('//div[@class="message-part"]');
  13. $this->assertCount(1, $msgParts, 'Message text parts');
  14. $paragraphs = $domxpath->query('//div[@class="message-part"]//p');
  15. $this->assertCount(2, $paragraphs);
  16. $html = $paragraphs[0]->ownerDocument->saveHTML($paragraphs[0]);
  17. $this->assertSame('<p><strong>Hello!</strong></p>', $html);
  18. $html = $paragraphs[1]->ownerDocument->saveHTML($paragraphs[1]);
  19. $this->assertSame("<p>I'm <em>really</em> happy that you're <em>reading</em> this!</p>", $html);
  20. $attchNames = $domxpath->query('//span[@class="attachment-name"]');
  21. $this->assertCount(0, $attchNames, 'Attachments');
  22. }
  23. public function testPlaintextAndMarkdownContent()
  24. {
  25. $domxpath = $this->runAndGetHtmlOutputDomxpath('60fb477df7365015fea1b6adc4e85d3dec0571f3260d609768f3427e6bfc8f61@example.net');
  26. $this->assertSame('Plaintext and markdown', $this->getScrubbedSubject($domxpath));
  27. $msgParts = $domxpath->query('//div[@class="message-part"]');
  28. $this->assertCount(2, $msgParts, 'Message text parts');
  29. $this->assertSame('Please read the attached markdown file.', $msgParts[0]->textContent);
  30. $paragraphs = $domxpath->query('//div[@class="message-part"]//p');
  31. $this->assertCount(2, $paragraphs);
  32. $html = $paragraphs[0]->ownerDocument->saveHTML($paragraphs[0]);
  33. $this->assertSame('<p><strong>Hello!</strong></p>', $html);
  34. $html = $paragraphs[1]->ownerDocument->saveHTML($paragraphs[1]);
  35. $this->assertSame("<p>I'm <em>really</em> happy that you're <em>reading</em> this!</p>", $html);
  36. $attchNames = $domxpath->query('//span[@class="attachment-name"]');
  37. $this->assertCount(1, $attchNames, 'Attachments');
  38. $this->assertSame('test.md', $attchNames[0]->textContent);
  39. }
  40. public function testPlaintextWithMarkdownAttachment()
  41. {
  42. $domxpath = $this->runAndGetHtmlOutputDomxpath('76fc626530d3253af13591c298d887acb801b440cdf3458da1882d667b8220aa@example.net');
  43. $this->assertSame('Plaintext with markdown attachment', $this->getScrubbedSubject($domxpath));
  44. $msgParts = $domxpath->query('//div[@class="message-part"]');
  45. $this->assertCount(1, $msgParts, 'Message text parts');
  46. $this->assertSame('Please read the attached markdown file.', $msgParts[0]->textContent);
  47. $attchNames = $domxpath->query('//span[@class="attachment-name"]');
  48. $this->assertCount(1, $attchNames, 'Attachments');
  49. $this->assertSame('test.md', $attchNames[0]->textContent);
  50. }
  51. }