protected function JSWebAssert::escapeHtml in Drupal 9
Same name and namespace in other branches
- 8 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
$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 474
Class
- JSWebAssert
- Defines a class with methods for asserting presence of elements during tests.
Namespace
Drupal\FunctionalJavascriptTestsCode
protected function escapeHtml($raw) {
return htmlspecialchars($raw, ENT_NOQUOTES | ENT_SUBSTITUTE, 'UTF-8');
}