You are here

function Drafty1992010Test::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 Drafty1992010Test::createTranslation()
Drafty1992010Test::testFieldTranslation in modules/drafty_1992010/Drafty1992010Test.test
Test if field based translation works.

File

modules/drafty_1992010/Drafty1992010Test.test, line 53

Class

Drafty1992010Test
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;
}