public function TitleTranslationTestCase::testFormTranslationWorkflow in Title 7
Tests taxonomy form translation workflow.
File
- tests/
TitleTranslationTestCase.test, line 190
Class
- TitleTranslationTestCase
- Tests for legacy field replacement.
Code
public function testFormTranslationWorkflow() {
// Create a taxonomy term and check that legacy fields are properly
// populated.
$original_values = array(
'name' => $this
->randomName(),
'description' => $this
->randomName(),
);
$langcode = 'en';
$edit = $this
->editValues($original_values, $langcode);
$this
->drupalPost('admin/structure/taxonomy/' . $this->vocabulary->machine_name . '/add', $edit, t('Save'));
$term = current(entity_load('taxonomy_term', FALSE, array(
'name' => $original_values['name'],
), TRUE));
$this
->assertEqual($term->description, $original_values['description'], t('Taxonomy term created.'));
// Translate the taxonomy term and check that both the original values and
// the translations were correctly stored.
$translated_values = array(
'name' => $this
->randomName(),
'description' => $this
->randomName(),
);
$translation_langcode = 'it';
$edit = $this
->editValues($translated_values, 'it');
$this
->drupalPost($translation_langcode . '/taxonomy/term/' . $term->tid . '/edit/add/' . $langcode . '/' . $translation_langcode, $edit, t('Save'));
$term = $this
->termLoad($term->tid);
$this
->assertTrue($this
->checkFieldValues($term, $translated_values, $translation_langcode, FALSE), t('Taxonomy term translation created.'));
$this
->assertTrue($this
->checkFieldValues($term, $original_values, $langcode), t('Taxonomy term original values preserved.'));
// Check that legacy fields have the correct values.
$this
->assertEqual($term->name, $original_values['name'], t('Taxonomy term name correctly stored.'));
$this
->assertEqual($term->description, $original_values['description'], t('Taxonomy term description correctly stored.'));
// Updated the taxonomy term translation and check that both the original
// values and the translations were correctly stored.
$translated_values = array(
'name' => $this
->randomName(),
'description' => $this
->randomName(),
);
$edit = $this
->editValues($translated_values, $translation_langcode);
$this
->drupalPost($translation_langcode . '/taxonomy/term/' . $term->tid . '/edit/' . $translation_langcode, $edit, t('Save'));
$term = $this
->termLoad($term->tid);
$this
->assertTrue($this
->checkFieldValues($term, $translated_values, $translation_langcode, FALSE), t('Taxonomy term translation updated.'));
$this
->assertTrue($this
->checkFieldValues($term, $original_values, $langcode), t('Taxonomy term original values preserved.'));
// Check that legacy fields have the correct values.
$this
->assertEqual($term->name, $original_values['name'], t('Taxonomy term name correctly stored.'));
$this
->assertEqual($term->description, $original_values['description'], t('Taxonomy term description correctly stored.'));
}