You are here

function TMGMTPluginsTestCase::testRemoteLanguagesMappings in Translation Management Tool 7

Tests remote languages mappings support in the tmgmt core.

File

tests/tmgmt.plugin.test, line 138

Class

TMGMTPluginsTestCase
Tests interaction between core and the plugins.

Code

function testRemoteLanguagesMappings() {
  $this
    ->loginAsAdmin();
  $this
    ->setEnvironment('de');
  $controller = $this->default_translator
    ->getController();
  $mappings = $controller
    ->getRemoteLanguagesMappings($this->default_translator);
  $this
    ->assertEqual($mappings, array(
    'en' => 'en-us',
    'de' => 'de-ch',
  ));
  $this
    ->assertEqual($controller
    ->mapToRemoteLanguage($this->default_translator, 'en'), 'en-us');
  $this
    ->assertEqual($controller
    ->mapToRemoteLanguage($this->default_translator, 'de'), 'de-ch');
  $this
    ->assertEqual($controller
    ->mapToLocalLanguage($this->default_translator, 'en-us'), 'en');
  $this
    ->assertEqual($controller
    ->mapToLocalLanguage($this->default_translator, 'de-ch'), 'de');
  $this->default_translator->settings['remote_languages_mappings']['de'] = 'de-de';
  $this->default_translator->settings['remote_languages_mappings']['en'] = 'en-uk';
  $this->default_translator
    ->save();
  $this
    ->assertEqual($controller
    ->mapToRemoteLanguage($this->default_translator, 'en'), 'en-uk');
  $this
    ->assertEqual($controller
    ->mapToRemoteLanguage($this->default_translator, 'de'), 'de-de');

  // Test the fallback.
  $info =& drupal_static('_tmgmt_plugin_info');
  $info['translator']['test_translator']['map remote languages'] = FALSE;
  $this
    ->assertEqual($controller
    ->mapToRemoteLanguage($this->default_translator, 'en'), 'en');
  $this
    ->assertEqual($controller
    ->mapToRemoteLanguage($this->default_translator, 'de'), 'de');
}