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