function HtmlToTextTest::testDrupalHtmlToTextArgs

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

Tests allowing tags in \Drupal\Core\Mail\MailFormatHelper::htmlToText().

File

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

Class

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

Namespace

Drupal\Tests\system\Functional\Mail

Code

public function testDrupalHtmlToTextArgs() {
    // The second parameter of \Drupal\Core\Mail\MailFormatHelper::htmlToText()
    // overrules the allowed tags.
    $this->assertHtmlToText('Drupal <b>Drupal</b> Drupal', "Drupal *Drupal* Drupal\n", 'Allowed <b> tag found', [
        'b',
    ]);
    $this->assertHtmlToText('Drupal <h1>Drupal</h1> Drupal', "Drupal Drupal Drupal\n", 'Disallowed <h1> tag not found', [
        'b',
    ]);
    $this->assertHtmlToText('Drupal <p><em><b>Drupal</b></em><p> Drupal', "Drupal Drupal Drupal\n", 'Disallowed <p>, <em>, and <b> tags not found', [
        'a',
        'br',
        'h1',
    ]);
    $this->assertHtmlToText('<html><body>Drupal</body></html>', "Drupal\n", 'Unsupported <html> and <body> tags not found', [
        'html',
        'body',
    ]);
}

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