function XssUnitTest::testT
Same name in other branches
- 8.9.x core/tests/Drupal/KernelTests/Core/Common/XssUnitTest.php \Drupal\KernelTests\Core\Common\XssUnitTest::testT()
- 10 core/tests/Drupal/KernelTests/Core/Common/XssUnitTest.php \Drupal\KernelTests\Core\Common\XssUnitTest::testT()
- 11.x core/tests/Drupal/KernelTests/Core/Common/XssUnitTest.php \Drupal\KernelTests\Core\Common\XssUnitTest::testT()
Tests t() functionality.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Common/ XssUnitTest.php, line 37
Class
- XssUnitTest
- Tests XSS filtering.
Namespace
Drupal\KernelTests\Core\CommonCode
public function testT() {
$text = t('Simple text');
$this->assertEquals('Simple text', $text, 't leaves simple text alone.');
$text = t('Escaped text: @value', [
'@value' => '<script>',
]);
$this->assertEquals('Escaped text: <script>', $text, 't replaces and escapes string.');
$text = t('Placeholder text: %value', [
'%value' => '<script>',
]);
$this->assertEquals('Placeholder text: <em class="placeholder"><script></em>', $text, 't replaces, escapes and themes string.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.