You are here

public function PotxTestCase::testDrupal7 in Translation template extractor 7.3

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

Test parsing of Drupal 7 module.

File

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

  // Parse and build the Drupal 7 module file.
  $filename = __DIR__ . '/potx_test_7.module';
  $this
    ->parseFile($filename, POTX_API_7);

  // Assert strings found in module source code.
  $this
    ->assertMsgID('Test menu item');
  $this
    ->assertMsgID('This is a test menu item');
  $this
    ->assertMsgID('This is a test string.');
  $this
    ->assertMsgID('test watchdog type');
  $this
    ->assertMsgID('My watchdog message');
  $this
    ->assertMsgID('PHP Syntax error gracefully handled');

  // No support for hook_perm() anymore. t() in hook_permissions().
  $this
    ->assertNoMsgID('test potx permission');
  $this
    ->assertNoMsgID('one more test potx permission');
  $this
    ->assertMsgID('Test potx permission');
  $this
    ->assertMsgID('Test potx permission description');
  $this
    ->assertMsgID('One more test potx permission');
  $this
    ->assertMsgID('One more test potx permission description');
  $this
    ->assertPluralID('1 test string', '@count test strings');
  $this
    ->assertPluralIDContext('1 test string in context', '@count test strings in context', 'Test context');
  $this
    ->assertMsgID('Test menu item description');
  $this
    ->assertMsgID('Test menu item description altered (1)');
  $this
    ->assertMsgID('Test menu item description altered (2)');
  $this
    ->assertMsgID('Test menu item title altered');
  $this
    ->assertNoMsgID('Installer only test string');
  $this
    ->assertMsgID('Dynamic callback test string');
  $this
    ->assertNoMsgIDContext('Installer string in context', 'Installer context');
  $this
    ->assertMsgIDContext('Dynamic string in context', 'Dynamic context');

  // Context support added.
  $this
    ->assertMsgIDContext('Test string in context', 'Test context');

  // Drush support.
  $this
    ->assertMsgID('This could have been in a drush file');

  // Look at installer strings.
  $this
    ->parseFile($filename, POTX_API_7, 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
    ->assertMsgIDContext('Installer string in context', 'Installer context');
  $this
    ->assertMsgIDContext('Dynamic string in context', 'Dynamic context');
  $this
    ->assert(count($this->potx_status) == 3, t('3 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] == 'Unexpected ;', t('Unexpected semicolon found.'));
  $this
    ->assert($this->potx_status[2][0] == $this->empty_error, t('Second empty error found.'));
}