function i18nVariableTestCase::testVariableLocalize in Internationalization 7
File
- i18n_variable/
i18n_variable.test, line 45 - Test case for multilingual variables
Class
- i18nVariableTestCase
- @file Test case for multilingual variables
Code
function testVariableLocalize() {
$this
->setUpContentTranslation();
// Create 2 nodes in different languages.
$first_title = $this
->randomName(10);
$first_body = $this
->randomString(50);
$first_node = $this
->createNode('page', $first_title, $first_body, $this->default_language);
$secondary_title = $this
->randomName(10);
$secondary_body = $this
->randomString(50);
$secondary_node = $this
->createNode('page', $secondary_title, $secondary_body, $this->secondary_language);
$this
->drupalGet('<front>', array(
'language' => i18n_language_object($this->default_language),
));
$this
->assertText(t('No front page content has been created yet.'));
$this
->drupalGet('<front>', array(
'language' => i18n_language_object($this->secondary_language),
));
$this
->assertText(t('No front page content has been created yet.'));
$edit = array(
'variables[site_name]' => 1,
'variables[site_frontpage]' => 1,
);
$this
->drupalPost('admin/config/regional/i18n/variable', $edit, t('Save configuration'));
$edit_first = array(
'site_frontpage' => 'node/' . $first_node->nid,
'site_name' => $this
->randomName(10),
);
$this
->drupalPost('admin/config/system/site-information', $edit_first, t('Save configuration'), array(
'language' => i18n_language_object($this->default_language),
));
$edit_secondary = array(
'site_frontpage' => 'node/' . $secondary_node->nid,
'site_name' => $this
->randomName(10),
);
$this
->drupalPost('admin/config/system/site-information', $edit_secondary, t('Save configuration'), array(
'language' => i18n_language_object($this->secondary_language),
));
$this
->drupalGet('<front>', array(
'language' => i18n_language_object($this->default_language),
));
$this
->assertText($edit_first['site_name']);
$this
->assertNoText(t('No front page content has been created yet.'));
$this
->assertText($first_title);
$this
->drupalGet('<front>', array(
'language' => i18n_language_object($this->secondary_language),
));
$this
->assertText($edit_secondary['site_name']);
$this
->assertNoText(t('No front page content has been created yet.'));
$this
->assertText($secondary_title);
}