public function PotxTestCase::testDrupal8 in Translation template extractor 7.2
Same name and namespace in other branches
- 6.3 tests/potx.test \PotxTestCase::testDrupal8()
- 7.3 tests/potx.test \PotxTestCase::testDrupal8()
Test parsing of Drupal 8 module.
File
- tests/
potx.test, line 234 - 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 = drupal_get_path('module', 'potx') . '/tests/potx_test_8.module';
$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
->assertMsgID('TranslationWrapper string');
$this
->assertMsgIDContext('TranslationWrapper string with context', 'With context');
$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');
}