function ThemeRenderAndAutoescapeTest::providerTestThemeRenderAndAutoescape
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Theme/ThemeRenderAndAutoescapeTest.php \Drupal\KernelTests\Core\Theme\ThemeRenderAndAutoescapeTest::providerTestThemeRenderAndAutoescape()
- 8.9.x core/tests/Drupal/KernelTests/Core/Theme/ThemeRenderAndAutoescapeTest.php \Drupal\KernelTests\Core\Theme\ThemeRenderAndAutoescapeTest::providerTestThemeRenderAndAutoescape()
- 10 core/tests/Drupal/KernelTests/Core/Theme/ThemeRenderAndAutoescapeTest.php \Drupal\KernelTests\Core\Theme\ThemeRenderAndAutoescapeTest::providerTestThemeRenderAndAutoescape()
Provide test examples.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Theme/ ThemeRenderAndAutoescapeTest.php, line 58
Class
- ThemeRenderAndAutoescapeTest
- Tests the theme_render_and_autoescape() function.
Namespace
Drupal\KernelTests\Core\ThemeCode
public static function providerTestThemeRenderAndAutoescape() {
return [
'empty string unchanged' => [
'',
'',
],
'simple string unchanged' => [
'ab',
'ab',
],
'int (scalar) cast to string' => [
111,
'111',
],
'float (scalar) cast to string' => [
2.1,
'2.1',
],
'> is escaped' => [
'>',
'>',
],
'Markup EM tag is unchanged' => [
Markup::create('<em>hi</em>'),
'<em>hi</em>',
],
'Markup SCRIPT tag is unchanged' => [
Markup::create('<script>alert("hi");</script>'),
'<script>alert("hi");</script>',
],
'EM tag in string is escaped' => [
'<em>hi</em>',
Html::escape('<em>hi</em>'),
],
'type link render array is rendered' => [
[
'#type' => 'link',
'#title' => 'Text',
'#url' => '<none>',
],
'<a href="">Text</a>',
],
'type markup with EM tags is rendered' => [
[
'#markup' => '<em>hi</em>',
],
'<em>hi</em>',
],
'SCRIPT tag in string is escaped' => [
'<script>alert(123)</script>',
Html::escape('<script>alert(123)</script>'),
],
'type plain_text render array EM tag is escaped' => [
[
'#plain_text' => '<em>hi</em>',
],
Html::escape('<em>hi</em>'),
],
'type hidden render array is rendered' => [
[
'#type' => 'hidden',
'#name' => 'foo',
'#value' => 'bar',
],
"<input type=\"hidden\" name=\"foo\" value=\"bar\" />\n",
],
];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.