You are here

public function HtmlToTextTest::testFootnoteReferences in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/system/tests/src/Functional/Mail/HtmlToTextTest.php \Drupal\Tests\system\Functional\Mail\HtmlToTextTest::testFootnoteReferences()

Test that footnote references are properly generated.

File

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

Class

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

Namespace

Drupal\Tests\system\Functional\Mail

Code

public function testFootnoteReferences() {
  global $base_path, $base_url;
  $source = <<<EOT
<a href="http://www.example.com/node/1">Host and path</a>
<br /><a href="http://www.example.com">Host, no path</a>
<br /><a href="{<span class="php-variable">$base_path</span>}node/1">Path, no host</a>
<br /><a href="node/1">Relative path</a>
EOT;
  $source = str_replace([
    "\r",
    "\n",
  ], '', $source);

  // @todo Footnote URLs should be absolute.
  // @todo The last two references should be combined.
  $text = <<<EOT
Host and path [1]
Host, no path [2]
Path, no host [3]
Relative path [4]

[1] http://www.example.com/node/1
[2] http://www.example.com
[3] {<span class="php-variable">$base_url</span>}/node/1
[4] node/1

EOT;
  $this
    ->assertHtmlToText($source, $text, 'Footnotes');
}