public function LanguageHierarchyBaseTestCase::addStringTranslation in Language Hierarchy 7
Translates given string into language of choice.
Parameters
string $string: String to translate.
string $translation: Translation of that string.
string $langcode: Target language of translation.
1 call to LanguageHierarchyBaseTestCase::addStringTranslation()
- LanguageHierarchyStringTranslationWebTestCase::testStringTranslation in tests/
language_hierarchy.test - Adds a language and tests string translation by users with the appropriate permissions.
File
- tests/
language_hierarchy.test, line 122 - Tests for Language Hierarchy module.
Class
- LanguageHierarchyBaseTestCase
- Base class for Language Hierarchy module tests.
Code
public function addStringTranslation($string, $translation, $langcode) {
$search = array(
'string' => $string,
'language' => 'all',
'translation' => 'all',
'group' => 'all',
);
$this
->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
// assertText() seems to remove the input field where $string always could be
// found, so this is not a false assert. See how assertNoText succeeds
// later.
$this
->assertText($string, 'Search found the string.');
$this
->assertRaw($this
->getLanguageIndicator($langcode), 'String is untranslated.');
// Assume this is the only result, given the random string.
$this
->clickLink(t('edit'));
// No t() here, it's surely not translated yet.
$this
->assertText($string, 'String found on edit screen.');
$edit = array(
"translations[{$langcode}]" => $translation,
);
$this
->drupalPost(NULL, $edit, t('Save translations'));
$this
->assertText(t('The string has been saved.'), 'The string has been saved.');
$this
->assertEqual($this
->getUrl(), url('admin/config/regional/translate/translate', array(
'absolute' => TRUE,
)), 'Correct page redirection.');
}