public function XssUnitTest::testT in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Common/XssUnitTest.php \Drupal\KernelTests\Core\Common\XssUnitTest::testT()
- 9 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 31
Class
- XssUnitTest
- Confirm that \Drupal\Component\Utility\Xss::filter() and check_url() work correctly, including invalid multi-byte sequences.
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.');
}