function JSWebAssert::escapeHtml
Same name in other branches
- 9 core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php \Drupal\FunctionalJavascriptTests\JSWebAssert::escapeHtml()
- 8.9.x core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php \Drupal\FunctionalJavascriptTests\JSWebAssert::escapeHtml()
- 10 core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php \Drupal\FunctionalJavascriptTests\JSWebAssert::escapeHtml()
Escapes HTML for testing.
Drupal's Html::escape() uses the ENT_QUOTES flag with htmlspecialchars() to escape both single and double quotes. With WebDriverTestBase testing the browser is automatically converting " and ' to double and single quotes respectively therefore we can not escape them when testing for escaped HTML.
Parameters
string $raw: The raw string to escape.
Return value
string The string with escaped HTML.
See also
Drupal\Component\Utility\Html::escape()
2 calls to JSWebAssert::escapeHtml()
- JSWebAssert::assertEscaped in core/
tests/ Drupal/ FunctionalJavascriptTests/ JSWebAssert.php - Passes if the raw text IS found escaped on the loaded page.
- JSWebAssert::assertNoEscaped in core/
tests/ Drupal/ FunctionalJavascriptTests/ JSWebAssert.php - Passes if the raw text IS NOT found escaped on the loaded page.
File
-
core/
tests/ Drupal/ FunctionalJavascriptTests/ JSWebAssert.php, line 539
Class
- JSWebAssert
- Defines a class with methods for asserting presence of elements during tests.
Namespace
Drupal\FunctionalJavascriptTestsCode
protected function escapeHtml($raw) : string {
return htmlspecialchars($raw, ENT_NOQUOTES | ENT_SUBSTITUTE, 'UTF-8');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.