function HtmlToTextTest::stringToHtml

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

Converts a string to its PHP source equivalent for display in test messages.

Parameters

$text: The text string to convert.

Return value

string An HTML representation of the text string that, when displayed in a browser, represents the PHP source code equivalent of $text.

File

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

Class

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

Namespace

Drupal\Tests\system\Unit\Mail

Code

protected function stringToHtml($text) : string {
    return '"' . str_replace([
        "\n",
        ' ',
    ], [
        '\\n',
        ' ',
    ], Html::escape($text)) . '"';
}

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