function HtmlToTextTest::testHeaderSeparation

Same name and namespace in other branches
  1. 9 core/modules/system/tests/src/Functional/Mail/HtmlToTextTest.php \Drupal\Tests\system\Functional\Mail\HtmlToTextTest::testHeaderSeparation()
  2. 10 core/modules/system/tests/src/Unit/Mail/HtmlToTextTest.php \Drupal\Tests\system\Unit\Mail\HtmlToTextTest::testHeaderSeparation()
  3. 11.x core/modules/system/tests/src/Unit/Mail/HtmlToTextTest.php \Drupal\Tests\system\Unit\Mail\HtmlToTextTest::testHeaderSeparation()

Test that headers are properly separated from surrounding text.

File

core/modules/system/tests/src/Functional/Mail/HtmlToTextTest.php, line 266

Class

HtmlToTextTest
Tests for <a href="/api/drupal/core%21lib%21Drupal%21Core%21Mail%21MailFormatHelper.php/function/MailFormatHelper%3A%3AhtmlToText/8.9.x" title="Transforms an HTML string into plain text, preserving its structure." class="local">\Drupal\Core\Mail\MailFormatHelper::htmlToText</a>().

Namespace

Drupal\Tests\system\Functional\Mail

Code

public function testHeaderSeparation() {
    $html = 'Drupal<h1>Drupal</h1>Drupal';
    // @todo There should be more space above the header than below it.
    $text = "Drupal\n======== DRUPAL ==============================================================\n\nDrupal\n";
    $this->assertHtmlToText($html, $text, 'Text before and after <h1> tag');
    $html = '<p>Drupal</p><h1>Drupal</h1>Drupal';
    // @todo There should be more space above the header than below it.
    $text = "Drupal\n\n======== DRUPAL ==============================================================\n\nDrupal\n";
    $this->assertHtmlToText($html, $text, 'Paragraph before and text after <h1> tag');
    $html = 'Drupal<h1>Drupal</h1><p>Drupal</p>';
    // @todo There should be more space above the header than below it.
    $text = "Drupal\n======== DRUPAL ==============================================================\n\nDrupal\n\n";
    $this->assertHtmlToText($html, $text, 'Text before and paragraph after <h1> tag');
    $html = '<p>Drupal</p><h1>Drupal</h1><p>Drupal</p>';
    $text = "Drupal\n\n======== DRUPAL ==============================================================\n\nDrupal\n\n";
    $this->assertHtmlToText($html, $text, 'Paragraph before and after <h1> tag');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.