You are here

function WebformLocalizationWebTestCase::createWebformTranslation in Webform Localization 7.4

Same name and namespace in other branches
  1. 7 tests/webform_localization.test \WebformLocalizationWebTestCase::createWebformTranslation()

Create a translation for the specified webform in the specified language.

Parameters

$node: The basic page to create translation for.

$title: Title of basic page in specified language.

$body: Body of basic page in specified language.

$language: Language code.

2 calls to WebformLocalizationWebTestCase::createWebformTranslation()
WebformLocalizationStringTranslationTestCase::testWebformLocalizationStringTranslation in tests/webform_localization.test
Test creating a webform and enabling localization by string translation
WebformLocalizationSubmissionTestCase::createTranslationNodes in tests/webform_localization.submission.test
Create the translated webform nodes.

File

tests/webform_localization.test, line 203
Webform localization module tests.

Class

WebformLocalizationWebTestCase
@file Webform localization module tests.

Code

function createWebformTranslation($node, $title, $body, $language) {
  $this
    ->drupalGet('node/add/webform', array(
    'query' => array(
      'translation' => $node->nid,
      'target' => $language,
    ),
  ));
  $langcode = $language;
  $body_key = "body[" . LANGUAGE_NONE . "][0][value]";

  //$this->assertFieldByXPath('//input[@id="edit-title"]', $node->title, "Original title value correctly populated.");

  //$this->assertFieldByXPath("//textarea[@name='$body_key']", $node->body[$node->language][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('Webform %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;
}