function HtmlTest::testDecodeEntitiesAndEscape
Same name in other branches
- 9 core/tests/Drupal/Tests/Component/Utility/HtmlTest.php \Drupal\Tests\Component\Utility\HtmlTest::testDecodeEntitiesAndEscape()
- 8.9.x core/tests/Drupal/Tests/Component/Utility/HtmlTest.php \Drupal\Tests\Component\Utility\HtmlTest::testDecodeEntitiesAndEscape()
- 11.x core/tests/Drupal/Tests/Component/Utility/HtmlTest.php \Drupal\Tests\Component\Utility\HtmlTest::testDecodeEntitiesAndEscape()
Tests relationship between escaping and decoding HTML entities.
@covers ::decodeEntities @covers ::escape
File
-
core/
tests/ Drupal/ Tests/ Component/ Utility/ HtmlTest.php, line 318
Class
Namespace
Drupal\Tests\Component\UtilityCode
public function testDecodeEntitiesAndEscape() : void {
$string = "<em>répété</em>";
$escaped = Html::escape($string);
$this->assertSame('<em>répét&eacute;</em>', $escaped);
$decoded = Html::decodeEntities($escaped);
$this->assertSame('<em>répété</em>', $decoded);
$decoded = Html::decodeEntities($decoded);
$this->assertSame('<em>répété</em>', $decoded);
$escaped = Html::escape($decoded);
$this->assertSame('<em>répété</em>', $escaped);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.