function XssUnitTest::testT
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Common/XssUnitTest.php \Drupal\KernelTests\Core\Common\XssUnitTest::testT()
- 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()
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() : void {
$text = t('Simple text');
$this->assertSame('Simple text', (string) $text, 't leaves simple text alone.');
$text = t('Escaped text: @value', [
'@value' => '<script>',
]);
$this->assertSame('Escaped text: <script>', (string) $text, 't replaces and escapes string.');
$text = t('Placeholder text: %value', [
'%value' => '<script>',
]);
$this->assertSame('Placeholder text: <em class="placeholder"><script></em>', (string) $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.