You are here

function EntityTranslationTestCase::createTranslation in Entity Translation 7

Create a translation.

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.

3 calls to EntityTranslationTestCase::createTranslation()
EntityTranslationHookTestCase::testFormWorkflow in tests/entity_translation.test
Test whether hooks are properly fired in the regular form workflow.
EntityTranslationIntegrationTestCase::testPathautoIntegration in tests/entity_translation.test
Tests Pathauto integration.
EntityTranslationTranslationTestCase::testFieldTranslation in tests/entity_translation.test
Test if field based translation works.
1 method overrides EntityTranslationTestCase::createTranslation()
EntityTranslationMenuTranslationTestCase::createTranslation in entity_translation_i18n_menu/entity_translation_i18n_menu.test
Create a translation with menu item.

File

tests/entity_translation.test, line 259
Tests for Entity translation module.

Class

EntityTranslationTestCase
Base class for entity translation module tests.

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');
  $this
    ->assertLinkByHref('node/' . $node->nid . '/edit/' . $langcode, 0, t('Translation edit link found. Translation created.'));
  return $node;
}