You are here

protected function TwigTransTest::assertTwigTransTags in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Theme/TwigTransTest.php \Drupal\system\Tests\Theme\TwigTransTest::assertTwigTransTags()

Asserts Twig trans tags.

1 call to TwigTransTest::assertTwigTransTags()
TwigTransTest::testTwigTransTags in core/modules/system/src/Tests/Theme/TwigTransTest.php
Test Twig "trans" tags.

File

core/modules/system/src/Tests/Theme/TwigTransTest.php, line 102
Contains \Drupal\system\Tests\Theme\TwigTransTest.

Class

TwigTransTest
Tests Twig "trans" tags.

Namespace

Drupal\system\Tests\Theme

Code

protected function assertTwigTransTags() {
  $this
    ->assertText('OH HAI SUNZ', '{% trans "Hello sun." %} was successfully translated.');
  $this
    ->assertText('O HAI SUNZZZZZZZ', '{% trans "Hello sun." with {"context": "Lolspeak"} %} was successfully translated.');
  $this
    ->assertText('O HERRO ERRRF.', '{{ "Hello Earth."|trans }} was successfully translated.');
  $this
    ->assertText('OH HAI TEH MUUN', '{% trans %}Hello moon.{% endtrans %} was successfully translated.');
  $this
    ->assertText('O HAI STARRRRR', '{% trans %} with {% plural count = 1 %} was successfully translated.');
  $this
    ->assertText('O HAI 2 STARZZZZ', '{% trans %} with {% plural count = 2 %} was successfully translated.');
  $this
    ->assertRaw('ESCAPEE: &"<>', '{{ token }} was successfully translated and prefixed with "@".');
  $this
    ->assertRaw('PLAYSHOLDR: <em class="placeholder">&amp;&quot;&lt;&gt;</em>', '{{ token|placeholder }} was successfully translated and prefixed with "%".');
  $this
    ->assertRaw('DIS complex token HAZ LENGTH OV: 3. IT CONTAYNZ: <em class="placeholder">12345</em> AN &amp;&quot;&lt;&gt;.', '{{ complex.tokens }} were successfully translated with appropriate prefixes.');
  $this
    ->assertText('I have context.', '{% trans %} with a context only msgid was excluded from translation.');
  $this
    ->assertText('I HAZ KONTEX.', '{% trans with {"context": "Lolspeak"} %} was successfully translated with context.');
  $this
    ->assertText('O HAI NU TXT.', '{% trans with {"langcode": "zz"} %} was successfully translated in specified language.');
  $this
    ->assertText('O HAI NU TXTZZZZ.', '{% trans with {"context": "Lolspeak", "langcode": "zz"} %} was successfully translated with context in specified language.');

  // Makes sure https://www.drupal.org/node/2489024 doesn't happen without
  // twig debug.
  $this
    ->assertNoText(pi(), 'Running php code inside a Twig trans is not possible.');
}