public function PotxTest::testDrupal8 in Translation template extractor 8
Test parsing of Drupal 8 module.
File
- tests/
src/ Kernel/ PotxTest.php, line 312
Class
- PotxTest
- Ensure that the translation template extractor functions properly.
Namespace
Drupal\Tests\potx\KernelCode
public function testDrupal8() {
// Parse and build the Drupal 8 module file.
$filename = $this->tests_root . '/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
->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
->assertPluralIdContext('1 PluralTranslatableMarkup test string in context with two @place @holders, short array syntax', '@count PluralTranslatableMarkup test strings in context with two @place @holders, short array sytanx', '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('TranslatableMarkup string with a @placeholder');
$this
->assertMsgIdContext('TranslatableMarkup string with a @placeholder and context', 'Test context');
$this
->assertMsgIdContext('TranslatableMarkup string with a @placeholder and trailing comma and context', 'Test context');
$this
->assertMsgIdContext('TranslatableMarkup string with two @place @holders and context', 'Test context');
$this
->assertMsgIdContext('TranslatableMarkup string with a @placeholder and short array syntax context', 'Test context');
$this
->assertMsgIdContext('TranslatableMarkup string with a @placeholder and trailing comma and short array syntax context', 'Test context');
$this
->assertMsgIdContext('TranslatableMarkup string with two @place @holders and short array syntax context', 'Test 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');
$this
->assertPotxErrors([
'Incorrect @Translation' => t('In @Translation, only one, non-empty static string is allowed in double quotes.'),
'First empty error' => $this->empty_error,
]);
}