function i18n_API_Tests::testBasicAPI in Internationalization 6
File
- tests/i18n_api.test, line 34
Class
- i18n_API_Tests
Code
function testBasicAPI() {
$language_count = count(language_list());
$this
->assertTrue($language_count > 1, 'Multiple languages created: ' . $language_count);
$this
->assertEqual(i18n_get_lang(), 'en', 'Default language (en) properly set.');
foreach (language_list() as $lang) {
i18n_variable_set('site_name', "Drupal-{$lang->name}", $lang->language);
}
variable_set('language_content_type_story', 1);
$neutral = $this
->drupalCreateNode(array(
'type' => 'story',
'promote' => 1,
));
$source = $this
->drupalCreateNode(array(
'type' => 'story',
'promote' => 1,
'language' => i18n_default_language(),
));
$translations = $this
->drupalCreateTranslations($source);
$this
->assertEqual(count($translations), $language_count, "Created {$language_count} {$source->type} translations.");
variable_set('i18n_selection_mode', 'simple');
foreach (language_list() as $lang) {
$this
->drupalGet('', array(
'language' => $lang,
));
$this
->assertText("Drupal-{$lang->name}", 'Checked translated site name: Drupal-' . $lang->name);
$display = array(
$translations[$lang->language],
$neutral,
);
$hide = $translations;
unset($hide[$lang->language]);
$this
->assertContent($display, $hide);
}
}