function HtmlToTextTest::testFootnoteReferences

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()
  2. 10 core/modules/system/tests/src/Unit/Mail/HtmlToTextTest.php \Drupal\Tests\system\Unit\Mail\HtmlToTextTest::testFootnoteReferences()
  3. 11.x core/modules/system/tests/src/Unit/Mail/HtmlToTextTest.php \Drupal\Tests\system\Unit\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 <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 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');
}

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