public function FieldCollectionBasicTestCase::testCopyingEntities in Field collection 7
Make sure that field_collection-entities are copied when host-entities do.
File
- ./
field_collection.test, line 402 - Tests for field_collections.
Class
- FieldCollectionBasicTestCase
- Test basics.
Code
public function testCopyingEntities() {
list($node, $entity) = $this
->createNodeWithFieldCollection();
// Create a copy of that node.
$node->nid = NULL;
$node->vid = NULL;
$node->is_new = TRUE;
node_save($node);
$item = $node->{$this->field_name}[LANGUAGE_NONE][0];
$this
->assertNotEqual($entity->item_id, $item['value']);
// Do a php clone to the $node object and save it.
$node2 = clone $node;
$node2->nid = NULL;
$node2->is_new = TRUE;
$node2->vid = NULL;
node_save($node2);
$item2 = $node2->{$this->field_name}[LANGUAGE_NONE][0];
$this
->assertNotEqual($item2['value'], $item['value']);
// Create another copy this time (needlessly) forcing a new revision.
$node->nid = NULL;
$node->vid = NULL;
$node->is_new = TRUE;
$node->revision = TRUE;
node_save($node);
$item3 = $node->{$this->field_name}[LANGUAGE_NONE][0];
$this
->assertNotEqual($item['value'], $item3['value']);
}