function TokenTest::providerTestReplaceEscaping
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Utility/TokenTest.php \Drupal\Tests\Core\Utility\TokenTest::providerTestReplaceEscaping()
- 8.9.x core/tests/Drupal/Tests/Core/Utility/TokenTest.php \Drupal\Tests\Core\Utility\TokenTest::providerTestReplaceEscaping()
- 10 core/tests/Drupal/Tests/Core/Utility/TokenTest.php \Drupal\Tests\Core\Utility\TokenTest::providerTestReplaceEscaping()
File
-
core/
tests/ Drupal/ Tests/ Core/ Utility/ TokenTest.php, line 282
Class
- TokenTest
- @coversDefaultClass \Drupal\Core\Utility\Token @group Utility
Namespace
Drupal\Tests\Core\UtilityCode
public static function providerTestReplaceEscaping() {
$data = [];
// No tokens. The first argument to Token::replace() should not be escaped.
$data['no-tokens'] = [
'muh',
[],
'muh',
];
$data['html-in-string'] = [
'<h1>Giraffe</h1>',
[],
'<h1>Giraffe</h1>',
];
$data['html-in-string-quote'] = [
'<h1>Giraffe"</h1>',
[],
'<h1>Giraffe"</h1>',
];
$data['simple-placeholder-with-plain-text'] = [
'<h1>[token:meh]</h1>',
[
'[token:meh]' => 'Giraffe"',
],
'<h1>' . Html::escape('Giraffe"') . '</h1>',
];
$data['simple-placeholder-with-safe-html'] = [
'<h1>[token:meh]</h1>',
[
'[token:meh]' => Markup::create('<em>Emphasized</em>'),
],
'<h1><em>Emphasized</em></h1>',
];
return $data;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.