You are here

public function HtmlToTextTest::testHeaderSeparation 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::testHeaderSeparation()

Test that headers are properly separated from surrounding text.

File

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

Class

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

Namespace

Drupal\system\Tests\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');
}