You are here

public function PotxTestCase::testDrupal8 in Translation template extractor 7.3

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

Test parsing of Drupal 8 module.

File

tests/potx.test, line 246
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 testDrupal8() {

  // Parse and build the Drupal 8 module file.
  $filename = __DIR__ . '/potx_test_8.module.txt';
  $this
    ->parseFile($filename, POTX_API_8);

  // Test parsing $this->t calls in D8 code
  $this
    ->assertMsgID('Using t inside D8 classes ($this->t)');

  // Assert strings found in module source code.
  $this
    ->assertMsgID('Good translation annotation');
  $this
    ->assertMsgID('Another good translation annotation');
  $this
    ->assertMsgID('Final good translation annotation');
  $this
    ->assertNoMsgIDContext('Good translation annotation', 'Translation test');
  $this
    ->assertMsgID('Translation in good context');
  $this
    ->assertMsgIDContext('Translation in good context', 'Translation test');
  $this
    ->assert(count($this->potx_status) == 2, t('2 error messages found'));
  $this
    ->assert($this->potx_status[0][0] == 'In @Translation, only one, non-empty static string is allowed in double quotes.', t('Incorrect @Translation found.'));
  $this
    ->assert($this->potx_status[1][0] == $this->empty_error, t('Second empty error found.'));
  $this
    ->assertPluralID('1 formatPlural test string', '@count formatPlural test strings');
  $this
    ->assertPluralIDContext('1 formatPlural test string in context', '@count formatPlural test strings in context', 'Test context');
  $this
    ->assertPluralID('1 translation->formatPlural test string', '@count translation->formatPlural test strings');
  $this
    ->assertPluralIDContext('1 translation->formatPlural test string in context', '@count translation->formatPlural test strings in context', 'Test context');
  $this
    ->assertPluralID('1 PluralTranslatableMarkup test string', '@count PluralTranslatableMarkup test strings');
  $this
    ->assertPluralIDContext('1 PluralTranslatableMarkup test string with context', '@count PluralTranslatableMarkup test strings with context', 'Test context');
  $this
    ->assertMsgID('TranslationWrapper string');
  $this
    ->assertMsgIDContext('TranslationWrapper string with context', 'With context');
  $this
    ->assertMsgID('TranslatableMarkup string');
  $this
    ->assertMsgID('TranslatableMarkup string without context');
  $this
    ->assertMsgIDContext('TranslatableMarkup string with long array context', 'With context');
  $this
    ->assertMsgIDContext('TranslatableMarkup string with short array context', 'With context');
  $this
    ->assertMsgIDContext('TranslatableMarkup string with long array followed by short array context', 'With context');
  $this
    ->assertMsgIDContext('TranslatableMarkup string with complicated tokens', 'With context');
  $this
    ->assertMsgIDContext('TranslatableMarkup string with complicated option tokens', 'With context');
  $this
    ->assertMsgID('Test translatable string inside an inline template');
  $this
    ->assertMsgID('Another test translatable string inside an inline template');
  $this
    ->assertMsgID('A translatable string inside an inline template, with double-quoted "#template" key');
  $this
    ->assertMsgID('Debug message');
  $this
    ->assertMsgID('Info message');
  $this
    ->assertMsgID('Notice message');
  $this
    ->assertMsgID('Warning message');
  $this
    ->assertMsgID('Error message');
  $this
    ->assertMsgID('Critical message');
  $this
    ->assertMsgID('Alert message');
  $this
    ->assertMsgID('Emergency message');
  $this
    ->assertMsgID('Log message');
  $this
    ->assertMsgID('Log message 2');
  $this
    ->assertMsgID('Log message 3');
}