function HtmlEscapedTextTest::providerToString
Same name in other branches
- 9 core/tests/Drupal/Tests/Component/Render/HtmlEscapedTextTest.php \Drupal\Tests\Component\Render\HtmlEscapedTextTest::providerToString()
- 8.9.x core/tests/Drupal/Tests/Component/Render/HtmlEscapedTextTest.php \Drupal\Tests\Component\Render\HtmlEscapedTextTest::providerToString()
- 11.x core/tests/Drupal/Tests/Component/Render/HtmlEscapedTextTest.php \Drupal\Tests\Component\Render\HtmlEscapedTextTest::providerToString()
Data provider for testToString().
See also
testToString()
File
-
core/
tests/ Drupal/ Tests/ Component/ Render/ HtmlEscapedTextTest.php, line 37
Class
- HtmlEscapedTextTest
- Tests the HtmlEscapedText class.
Namespace
Drupal\Tests\Component\RenderCode
public static function providerToString() {
$prophet = new Prophet();
// Checks that invalid multi-byte sequences are escaped.
$tests[] = [
"Foo\xc0bar",
'Foo�bar',
'Escapes invalid sequence "Foo\\xC0bar"',
];
$tests[] = [
"\xc2\"",
'�"',
'Escapes invalid sequence "\\xc2\\""',
];
$tests[] = [
"Foo ÿñ",
"Foo ÿñ",
'Does not escape valid sequence "Foo ÿñ"',
];
// Checks that special characters are escaped.
$script_tag = $prophet->prophesize(MarkupInterface::class);
$script_tag->__toString()
->willReturn('<script>');
$script_tag = $script_tag->reveal();
$tests[] = [
$script_tag,
'<script>',
'Escapes <script> even inside an object that implements MarkupInterface.',
];
$tests[] = [
"<script>",
'<script>',
'Escapes <script>',
];
$tests[] = [
'<>&"\'',
'<>&"'',
'Escapes reserved HTML characters.',
];
$special_chars = $prophet->prophesize(MarkupInterface::class);
$special_chars->__toString()
->willReturn('<>&"\'');
$special_chars = $special_chars->reveal();
$tests[] = [
$special_chars,
'<>&"'',
'Escapes reserved HTML characters even inside an object that implements MarkupInterface.',
];
return $tests;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.