You are here

function EntityTranslationUpgradeTestCase::createContentTranslationTranslation in Entity Translation 7

See also

TranslationTestCase::createTranslation

1 call to EntityTranslationUpgradeTestCase::createContentTranslationTranslation()
EntityTranslationUpgradeTestCase::testUpgradeContentToEntityTranslation in entity_translation_upgrade/entity_translation_upgrade.test
Tests copying of source node's body value in the add translation form page.

File

entity_translation_upgrade/entity_translation_upgrade.test, line 89
Tests for Entity Translation module.

Class

EntityTranslationUpgradeTestCase
Tests for the upgrade translation process.

Code

function createContentTranslationTranslation($node, $title, $body, $language) {
  $this
    ->drupalGet('node/add/page', array(
    'query' => array(
      'translation' => $node->nid,
      'target' => $language,
    ),
  ));
  $langcode = LANGUAGE_NONE;
  $body_key = "body[{$langcode}][0][value]";
  $this
    ->assertFieldByXPath('//input[@id="edit-title"]', $node->title, "Original title value correctly populated.");
  $this
    ->assertFieldByXPath("//textarea[@name='{$body_key}']", $node->body[LANGUAGE_NONE][0]['value'], "Original body value correctly populated.");
  $edit = array();
  $edit["title"] = $title;
  $edit[$body_key] = $body;
  $this
    ->drupalPost(NULL, $edit, t('Save'));
  $this
    ->assertRaw(t('Basic page %title has been created.', array(
    '%title' => $title,
  )), 'Translation created.');

  // Check to make sure that translation was successful.
  $translation = $this
    ->drupalGetNodeByTitle($title);
  $this
    ->assertTrue($translation, 'Node found in database.');
  $this
    ->assertTrue($translation->tnid == $node->nid, 'Translation set id correctly stored.');
  return $translation;
}