public function PotxTestCase::testDrupal5 in Translation template extractor 7.2
Same name and namespace in other branches
- 6.3 tests/potx.test \PotxTestCase::testDrupal5()
- 7.3 tests/potx.test \PotxTestCase::testDrupal5()
- 7 tests/potx.test \PotxTestCase::testDrupal5()
Test parsing of Drupal 5 module.
File
- tests/
potx.test, line 31 - 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 testDrupal5() {
// Parse and build the Drupal 5 module file.
$filename = drupal_get_path('module', 'potx') . '/tests/potx_test_5.module';
$this
->parseFile($filename, POTX_API_5);
// Assert strings found in module source code.
$this
->assertMsgID('Test menu item in 5');
$this
->assertMsgID('This is a test menu item in 5');
$this
->assertMsgID('This is a test string.');
$this
->assertMsgID('test watchdog type');
// No support for instant t() in watchdog.
$this
->assertNoMsgID('My watchdog message');
$this
->assertMsgID('test potx permission');
$this
->assertMsgID('one more test potx permission');
$this
->assertPluralID('1 test string', '@count test strings');
// Installer string should not appear in runtime output.
$this
->assertNoMsgID('Installer only test string');
$this
->assertMsgID('Dynamic callback test string');
$this
->assertNoMsgID('Installer string in context');
// No context support yet.
$this
->assertNoMsgIDContext('Test string in context', 'Test context');
$this
->assertMsgID('Test string in context');
$this
->assertNoMsgIDContext('Dynamic string in context', 'Dynamic context');
$this
->assertMsgID('Dynamic string in context');
// The singular/plural will not even be found without context, because
// Drupal 5 does not have support for args on format_plural.
$this
->assertNoMsgID('1 test string in context');
$this
->assertNoPluralIDContext('1 test string in context', '@count test strings in context', 'Test context');
// Look at installer strings.
$this
->parseFile($filename, POTX_API_5, POTX_STRING_INSTALLER);
$this
->assertMsgID('Installer only test string');
$this
->assertMsgID('Dynamic callback test string');
$this
->assertNoMsgID('1 test string');
$this
->assertNoMsgID('This is a test string.');
$this
->assertNoMsgIDContext('Installer string in context', 'Installer context');
$this
->assertMsgID('Installer string in context');
$this
->assertNoMsgIDContext('Dynamic string in context', 'Dynamic context');
$this
->assertMsgID('Dynamic string in context');
$this
->assert(count($this->potx_status) == 4, t('4 error messages found'));
$this
->assert($this->potx_status[0][0] == $this->empty_error, t('First empty error found.'));
$this
->assert($this->potx_status[1][0] == $this->empty_error, t('Second empty error found.'));
$this
->assert($this->potx_status[2][0] == 'In format_plural(), the singular and plural strings should be literal strings. There should be no variables, concatenation, constants or even a t() call there.', t('Fourth error found.'));
$this
->assert($this->potx_status[3][0] == $this->empty_error, t('Third empty error found.'));
}