public function FieldCollectionContentTranslationTestCase::testContentTranslation in Field collection 7
Ensure field collections are cloned to new entities on content translation.
File
- ./
field_collection.test, line 641 - Tests for field_collections.
Class
- FieldCollectionContentTranslationTestCase
- Test using field collection with content that gets translated.
Code
public function testContentTranslation() {
// Create "Article" content.
$edit['title'] = self::randomName();
$edit['body[' . LANGUAGE_NONE . '][0][value]'] = self::randomName();
$edit['language'] = 'en';
$field_collection_name = 'field_test_collection[' . LANGUAGE_NONE . '][0][field_text][' . LANGUAGE_NONE . '][0][value]';
$edit[$field_collection_name] = self::randomName();
$this
->drupalPost('node/add/article', $edit, t('Save'));
$this
->assertRaw(t('Article %title has been created.', array(
'%title' => $edit['title'],
)), 'Article created.');
$node1 = $this
->drupalGetNodeByTitle($edit['title']);
$this
->drupalGet('node/' . $node1->nid . '/edit');
$this
->drupalGet('node/' . $node1->nid . '/translate');
$this
->drupalGet('node/add/article', array(
'query' => array(
'translation' => $node1->nid,
'target' => 'de',
),
));
// Suffix translations with the langcode.
unset($edit['language']);
$edit['title'] .= 'DE';
$edit[$field_collection_name] .= 'DE';
$this
->drupalPost('node/add/article', $edit, t('Save'), array(
'query' => array(
'translation' => $node1->nid,
'target' => 'de',
),
));
$node2 = $this
->drupalGetNodeByTitle($edit['title']);
// Ensure that our new node is the translation of the first one.
$this
->assertEqual($node1->nid, $node2->tnid, 'Succesfully created translation.');
// And check to see that their field collections are different.
$this
->assertNotEqual($node1->field_test_collection, $node2->field_test_collection, 'Field collections between translation source and translation differ.');
}