You are here

public function MultifieldEntityTranslationTestCase::testEntityTranslation in Multifield 7

Same name and namespace in other branches
  1. 7.2 tests/MultifieldEntityTranslationTestCase.test \MultifieldEntityTranslationTestCase::testEntityTranslation()

File

tests/MultifieldEntityTranslationTestCase.test, line 84

Class

MultifieldEntityTranslationTestCase

Code

public function testEntityTranslation() {
  $this
    ->drupalGet('node/add/' . $this->nodeType->type);
  $data['title'] = 'Test translated node';
  $data['field_multifield[und][0][field_text1][und][0][value]'] = 'English1';
  $data['field_multifield[und][0][field_text2][und][0][value]'] = 'English2';
  $this
    ->drupalPost(NULL, $data, 'Save');
  $node = $this
    ->drupalGetNodeByTitle($data['title'], TRUE);
  $this
    ->drupalGet('node/' . $node->nid . '/edit/add/en/es');
  $data = array();
  $data['field_multifield[es][0][field_text1][und][0][value]'] = 'Spanish1';
  $data['field_multifield[es][0][field_text2][und][0][value]'] = 'Spanish2';
  $this
    ->drupalPost(NULL, $data, 'Save');
  $node = node_load($node->nid, NULL, TRUE);
  $expected = array();
  $expected['en'][0]['id'] = '1';
  $expected['en'][0]['field_text1'][LANGUAGE_NONE][0] = array(
    'value' => 'English1',
    'format' => NULL,
    'safe_value' => 'English1',
  );
  $expected['en'][0]['field_text2'][LANGUAGE_NONE][0] = array(
    'value' => 'English2',
    'format' => NULL,
    'safe_value' => 'English2',
  );
  $expected['es'][0]['id'] = '1';
  $expected['es'][0]['field_text1'][LANGUAGE_NONE][0] = array(
    'value' => 'Spanish1',
    'format' => NULL,
    'safe_value' => 'Spanish1',
  );
  $expected['es'][0]['field_text2'][LANGUAGE_NONE][0] = array(
    'value' => 'Spanish2',
    'format' => NULL,
    'safe_value' => 'Spanish2',
  );
  $this
    ->assertIdentical($node->field_multifield, $expected);
}