You are here

function OgTranslationTestCase::createTranslation in Organic groups 7

Create a translation for the specified basic page in the specified language.

Parameters

object $node The basic page to create translation for.:

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

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

string $language Language code.:

1 call to OgTranslationTestCase::createTranslation()
OgTranslationTestCase::testOgNodeLocale in ./og.test
Test disabling OG fields on translated content.

File

./og.test, line 1017

Class

OgTranslationTestCase
Test the multilangual groups.

Code

function createTranslation($node, $title, $body, $language) {
  $this
    ->drupalGet('node/add/page', array(
    'query' => array(
      'translation' => $node->nid,
      'target' => $language,
    ),
  ));
  $body_key = "body[und][0][value]";
  $this
    ->assertFieldByXPath('//input[@id="edit-title"]', $node->title, t('Original title value correctly populated.'));
  $this
    ->assertFieldByXPath("//textarea[@name='{$body_key}']", $node->body[LANGUAGE_NONE][0]['value'], t('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,
  )), t('Translation created.'));

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