You are here

public function HtmlToTextTest::testDrupalHtmlToTextParagraphs in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Mail/HtmlToTextTest.php \Drupal\system\Tests\Mail\HtmlToTextTest::testDrupalHtmlToTextParagraphs()

Test that combinations of paragraph breaks, line breaks, linefeeds, and spaces are properly handled.

File

core/modules/system/src/Tests/Mail/HtmlToTextTest.php, line 319
Contains \Drupal\system\Tests\Mail\HtmlToTextTest.

Class

HtmlToTextTest
Tests for \Drupal\Core\Mail\MailFormatHelper::htmlToText().

Namespace

Drupal\system\Tests\Mail

Code

public function testDrupalHtmlToTextParagraphs() {
  $tests = array();
  $tests[] = array(
    'html' => "<p>line 1<br />\nline 2<br />line 3\n<br />line 4</p><p>paragraph</p>",
    // @todo Trailing line breaks should be trimmed.
    'text' => "line 1\nline 2\nline 3\nline 4\n\nparagraph\n\n",
  );
  $tests[] = array(
    'html' => "<p>line 1<br /> line 2</p> <p>line 4<br /> line 5</p> <p>0</p>",
    // @todo Trailing line breaks should be trimmed.
    'text' => "line 1\nline 2\n\nline 4\nline 5\n\n0\n\n",
  );
  foreach ($tests as $test) {
    $this
      ->assertHtmlToText($test['html'], $test['text'], 'Paragraph breaks');
  }
}