You are here

public function PotxTestCase::testDrupal7 in Translation template extractor 7.2

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

Test parsing of Drupal 7 module.

File

tests/potx.test, line 135
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 = drupal_get_path('module', 'potx') . '/tests/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');

  // 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');

  // 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) == 2, t('2 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.'));
}