function Drupali18nTestCase::createNodeTranslation in Internationalization 7
Create a translation for the specified node in the specified language.
Parameters
$node: The basic page to create translation for.
$title: Title of node in specified language.
$body: Body of node in specified language.
$language: Language code.
1 call to Drupali18nTestCase::createNodeTranslation()
- Drupali18nTestCase::createNodeTranslationSet in ./
i18n.test - Create translation set from a node
File
- ./
i18n.test, line 187 - Base class for Internationalization tests
Class
- Drupali18nTestCase
- @file Base class for Internationalization tests
Code
function createNodeTranslation($node, $language, $title = NULL, $body = NULL) {
$body = $body ? $body : $this
->randomName();
$title = $title ? $title : $this
->randomName();
$this
->drupalGet('node/add/' . $node->type, array(
'query' => array(
'translation' => $node->nid,
'target' => $language->language,
),
));
$this
->assertFieldByXPath('//input[@id="edit-title"]', $node->title, "Original title value correctly populated.");
$field_lang = field_language('node', $node, 'body');
$body_key = "body[und][0][value]";
$this
->assertFieldByXPath("//textarea[@name='{$body_key}']", $node->body[$field_lang][0]['value'], "Original body value correctly populated.");
$edit = array();
$edit["title"] = $title;
$edit[$body_key] = $body;
$this
->drupalPost(NULL, $edit, t('Save'));
$info = node_type_load($node->type);
$message = t('@name %title has been created.', array(
'@name' => $info->name,
'%title' => $title,
));
$this
->assertRaw($message);
// Check to make sure that translation was successful.
$translation = $this
->drupalGetNodeByTitle($title);
$this
->assertTrue($translation, t('Node found in database.'));
$this
->assertTrue($translation->tnid == $node->nid, t('Translation set id correctly stored.'));
return $translation;
}