You are here

public function LanguageHierarchyI18nVariableTranslationWebTestCase::testVariableUITranslation in Language Hierarchy 7

Test translating a variable, with hierarchy.

File

modules/i18n_variable_hierarchy/i18n_variable_hierarchy.test, line 51
Tests for Language Hierarchy module.

Class

LanguageHierarchyI18nVariableTranslationWebTestCase
Functional tests for translatable variables.

Code

public function testVariableUITranslation() {
  $this
    ->loginAdminUser();

  // Add languages used by this test case.
  $this
    ->addLanguages();
  $this
    ->enableUrlLanguageDetection();
  $parent_translation = $this
    ->randomName(10);
  $child_translation = $this
    ->randomName(10);

  // Set for parent language (pt).
  $edit = array(
    'site_slogan' => $parent_translation,
  );
  $this
    ->post('pt', 'admin/config/system/site-information', $edit, t('Save configuration', array(), array(
    'langcode' => 'pt',
  )));

  // Set for child language (pt-pt).
  $edit = array(
    'site_slogan' => $child_translation,
  );
  $this
    ->post('pt-pt', 'admin/config/system/site-information', $edit, t('Save configuration', array(), array(
    'langcode' => 'pt-pt',
  )));
  $this
    ->drupalLogout();
  $this
    ->get('pt-br', '');
  $this
    ->assertText($parent_translation, 'Slogan is inherited from parent language.');
  $this
    ->get('pt-pt', '');
  $this
    ->assertText($child_translation, 'Slogan is taken from current language.');
}