You are here

function XssUnitTest::testT in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/system/src/Tests/Common/XssUnitTest.php \Drupal\system\Tests\Common\XssUnitTest::testT()

Tests t() functionality.

File

core/modules/system/src/Tests/Common/XssUnitTest.php, line 36
Contains \Drupal\system\Tests\Common\XssUnitTest.

Class

XssUnitTest
Confirm that \Drupal\Component\Utility\Xss::filter() and check_url() work correctly, including invalid multi-byte sequences.

Namespace

Drupal\system\Tests\Common

Code

function testT() {
  $text = t('Simple text');
  $this
    ->assertEqual($text, 'Simple text', 't leaves simple text alone.');
  $text = t('Escaped text: @value', array(
    '@value' => '<script>',
  ));
  $this
    ->assertEqual($text, 'Escaped text: &lt;script&gt;', 't replaces and escapes string.');
  $text = t('Placeholder text: %value', array(
    '%value' => '<script>',
  ));
  $this
    ->assertEqual($text, 'Placeholder text: <em class="placeholder">&lt;script&gt;</em>', 't replaces, escapes and themes string.');
}