i18n_variable_hierarchy.test in Language Hierarchy 7
Tests for Language Hierarchy module.
File
modules/i18n_variable_hierarchy/i18n_variable_hierarchy.testView source
<?php
/**
* @file
* Tests for Language Hierarchy module.
*/
/**
* Functional tests for translatable variables.
*/
class LanguageHierarchyI18nVariableTranslationWebTestCase extends LanguageHierarchyBaseTestCase {
protected $admin_user_permissions = array(
'administer languages',
'access administration pages',
'administer site configuration',
);
public static function getInfo() {
return array(
'name' => 'Variable translation hierarchy',
'description' => 'Test variable translation with language inheritance.',
'group' => 'Language Hierarchy',
);
}
public function setUp() {
parent::setUp('i18n_variable_hierarchy', 'language_hierarchy_test');
}
/**
* Test translating a variable, with hierarchy.
*/
public function testI18nVariableTranslation() {
$this
->loginAdminUser();
// Add languages used by this test case.
$this
->addLanguages();
$this
->drupalLogout();
$parent_translation = $this
->randomName(10);
$child_translation = $this
->randomName(10);
i18n_variable_set('site_slogan', $parent_translation, 'pt');
i18n_variable_set('site_slogan', $child_translation, 'pt-pt');
$this
->assertEqual($parent_translation, i18n_variable_get('site_slogan', 'pt-br'));
$this
->assertEqual($child_translation, i18n_variable_get('site_slogan', 'pt-pt'));
}
/**
* Test translating a variable, with hierarchy.
*/
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.');
}
}
Classes
Name | Description |
---|---|
LanguageHierarchyI18nVariableTranslationWebTestCase | Functional tests for translatable variables. |