function HtmlToTextTest::testFootnoteReferences

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

Tests that footnote references are properly generated.

File

core/modules/system/tests/src/Unit/Mail/HtmlToTextTest.php, line 280

Class

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

Namespace

Drupal\Tests\system\Unit\Mail

Code

public function testFootnoteReferences() : void {
    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');
}

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