function EntityTranslationTranslationTestCase::testLocaleLanguageWidgetTranslation in Entity Translation 7
Tests the interplay of the locale language selector on a new Page node.
Add a new Page node in a given language (using URL language detection). On the node page form, use the Locale language field to set the new node's language to a language different from the URL language. Make sure that the newly created node has translatable fields created in the Locale's set language (and not the one coming from the URL).
File
- tests/
entity_translation.test, line 351 - Tests for Entity translation module.
Class
- EntityTranslationTranslationTestCase
- Basic tests for the translation creation/editing workflow.
Code
function testLocaleLanguageWidgetTranslation() {
variable_set('entity_translation_test_disable_form_cache', TRUE);
// Create Basic page in Spanish.
$this
->drupalGet('es/node/add/page');
$node_title = $this
->randomName();
$node_body = $this
->randomName();
$edit["title"] = $node_title;
$edit["body[es][0][value]"] = $node_body;
// But switch the locale field to English.
$edit['language'] = 'en';
$this
->drupalPost(NULL, $edit, t('Save'));
$node = $this
->drupalGetNodeByTitle($node_title);
$this
->assertTrue(in_array('en', array_keys($node->body)), 'Locale field language settings takes precedence.');
}