You are here

function DraftyEntityTranslationTest::createTranslation in Drafty 7

Create a translation.

This overrides because with drafty, asserting an 'edit' link for a translation fails when the revision with the added translation has not yet been published.

Parameters

$node: Node of the basic page to create translation for.

$title: Title of the basic page in the specified language.

$body: Body of the basic page in the specified language.

$langcode: The language code to be assigned to the specified values.

Overrides EntityTranslationTestCase::createTranslation

1 call to DraftyEntityTranslationTest::createTranslation()
DraftyEntityTranslationTest::testFieldTranslation in tests/DraftyEntityTranslationTest.test
Test if field based translation works.

File

tests/DraftyEntityTranslationTest.test, line 53

Class

DraftyEntityTranslationTest
Test draft revisions with entity translation.

Code

function createTranslation($node, $title, $body, $langcode, $source_langcode = 'en') {
  $this
    ->drupalGet('node/' . $node->nid . '/edit/add/' . $source_langcode . '/' . $langcode);
  $body_key = "body[{$langcode}][0][value]";
  $this
    ->assertFieldByXPath("//textarea[@name='{$body_key}']", $node->body[$source_langcode][0]['value'], 'Original body value correctly populated.');
  $this
    ->assertFieldById('edit-body-' . $langcode . '-add-more', t('Add another item'), t('Add another item button found.'));
  $edit = array();
  $edit[$body_key] = $body;
  $this
    ->drupalPost(NULL, $edit, t('Save'));
  $this
    ->drupalGet('node/' . $node->nid . '/translate');
  return $node;
}