function SimpleNewsI18nTestCase::testCategoryTranslation in Simplenews 7
File
- tests/simplenews.test, line 1686
- Simplenews test functions.
Class
- SimpleNewsI18nTestCase
- Tests for I18N integration.
Code
function testCategoryTranslation() {
$this
->drupalLogin($this->admin_user);
$edit = array(
'i18n_string_allowed_formats[plain_text]' => 'plain_text',
);
$this
->drupalPost('admin/config/regional/i18n/strings', $edit, t('Save configuration'));
$vocabulary = taxonomy_vocabulary_machine_name_load('newsletter');
$vocabulary->i18n_mode = I18N_MODE_LOCALIZE;
taxonomy_vocabulary_save($vocabulary);
drupal_static_reset('i18n_taxonomy_vocabulary_mode');
$tid = $this
->getRandomNewsletter();
$term = taxonomy_term_load($tid);
taxonomy_term_save($term);
$tid = array_shift(simplenews_categories_load_multiple())->tid;
list($textgroup, $context) = i18n_string_context(array(
'taxonomy',
'term',
$tid,
'name',
));
i18n_string_textgroup($textgroup)
->update_translation($context, 'es', $es_name = $this
->randomName());
list($textgroup, $context) = i18n_string_context(array(
'taxonomy',
'term',
$tid,
'description',
));
i18n_string_textgroup($textgroup)
->update_translation($context, 'es', $es_description = $this
->randomName());
$this
->drupalGet('user/' . $this->admin_user->uid . '/edit/simplenews');
$this
->assertText(t('Drupal newsletter'));
$this
->drupalGet('es/user/' . $this->admin_user->uid . '/edit/simplenews');
$this
->assertText($es_name, t('Category name is translated.'));
}