public function HtmlTest::testDecodeEntitiesAndEscape in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Component/Utility/HtmlTest.php \Drupal\Tests\Component\Utility\HtmlTest::testDecodeEntitiesAndEscape()
- 9 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 311
Class
Namespace
Drupal\Tests\Component\UtilityCode
public function testDecodeEntitiesAndEscape() {
$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);
}