You are here

public function PotxTestCase::testDrupal5 in Translation template extractor 7

Same name and namespace in other branches
  1. 6.3 tests/potx.test \PotxTestCase::testDrupal5()
  2. 7.3 tests/potx.test \PotxTestCase::testDrupal5()
  3. 7.2 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
    ->assertMsgID('1 test string');
  $this
    ->assertPluralID('@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');

  // 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) == 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] == $this->empty_error, t('Second empty error found.'));
  $this
    ->assert($this->potx_status[2][0] == $this->empty_error, t('Third empty error found.'));
}