function i18n_API_Tests::testBasicAPI in Internationalization 6
File
- tests/
i18n_api.test, line 34
Class
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.');
// Set site name for each language and check pages later
foreach (language_list() as $lang) {
i18n_variable_set('site_name', "Drupal-{$lang->name}", $lang->language);
}
// Enable language switcher block
//$this->enableBlock('locale', 0);
//$this->dumpTable('blocks');
// Create some content and check selection modes
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 fails because the _get_translations() function has static caching
//$this->assertEqual(count(translation_node_get_translations($source->tnid)), $language_count, "Created $language_count $source->type translations.");
$this
->assertEqual(count($translations), $language_count, "Created {$language_count} {$source->type} translations.");
// Default selection module, only language neutral and current
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);
}
}