You are here

public function PotxTestCase::testDrupal8Twig in Translation template extractor 7.3

Same name and namespace in other branches
  1. 6.3 tests/potx.test \PotxTestCase::testDrupal8Twig()
  2. 7.2 tests/potx.test \PotxTestCase::testDrupal8Twig()

Test parsing of Drupal 8 Twig templates.

File

tests/potx.test, line 202
Tests to ensure that the template extractor works as intended.

Class

PotxTestCase
@file Tests to ensure that the template extractor works as intended.

Code

public function testDrupal8Twig() {
  $filename = __DIR__ . '/potx_test_8.html.twig';
  $this
    ->parseFile($filename, POTX_API_8);
  $this
    ->assertMsgID('This is a translated string.');
  $this
    ->assertMsgID('A double-quoted string');
  $this
    ->assertMsgID('Here\'s a double-quoted "and escaped" string.');
  $this
    ->assertMsgID("Here's a string with an escaped quote.");
  $this
    ->assertNoMsgID('This is a concatenated string that should not be picked up.');
  $this
    ->assertNoMsgID('This is a concatenated string ');
  $this
    ->assertNoMsgID('that should not be picked up.');
  $this
    ->assertNoMsgID('This is an untranslated string.');
  $this
    ->assert(count($this->potx_status) == 1, t('1 error message found'));
  $this
    ->assert($this->potx_status[0][0] == t('Uses of the t filter in Twig templates should start with a single literal string, and should not be chained.'), t('Concatenation error found.'));
  $this
    ->assertMsgID('Hello sun.');
  $this
    ->assertMsgIDContext('Hello sun, with context.', 'Lolspeak');
  $this
    ->assertMsgID('Hello Earth.');
  $this
    ->assertMsgID('Hello moon.');
  $this
    ->assertPluralID('Hello star.', 'Hello @count stars.');
  $this
    ->assertMsgID('Escaped: @string');
  $this
    ->assertMsgID('Placeholder: %string');
  $this
    ->assertMsgID('This @node.type is submitted by @author.name, and has a length of: @count. It contains: %node.numbers and @node.bad_text.');
  $this
    ->assertMsgIDContext('I have context.', 'Lolspeak');
  $this
    ->assertNoMsgIDContext('I have no context.', 'zz');
  $this
    ->assertMsgIDContext('I have context and another parameter.', 'Lolspeak');
  $this
    ->assertMsgID('A multiline\\n    trans block.');
  $this
    ->assertMsgID('Test string with @extra_filter');
  $this
    ->assertMsgID('Test string with @multiple_filters');
  $this
    ->assertMsgID('Test string with %multiple_filters');
  $this
    ->assertMsgID('Meta-data for a help topic title');
  $this
    ->assertNoMsgID('Meta-data that should not be translated');
}