function XssUnitTest::testT

Tests t() functionality.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Common/XssUnitTest.php, line 40
Definition of Drupal\system\Tests\Common\XssUnitTest.

Class

XssUnitTest
Tests for filter_xss() and check_url().

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.');
  $text = t('Verbatim text: !value', array(
    '!value' => '<script>',
  ));
  $this
    ->assertEqual($text, 'Verbatim text: <script>', 't replaces verbatim string as-is.');
}