public function EntityReferenceTermMergeWebTestCase::testEntityReferenceField in Term Merge 7
Verify that entity reference field values get update upon term merging.
File
- ./
term_merge.test, line 1702 - Test the Term Merge module.
Class
- EntityReferenceTermMergeWebTestCase
- Test integration with Entity Reference module.
Code
public function testEntityReferenceField() {
$terms = array(
'trunk' => NULL,
'branch' => NULL,
);
$nodes = array();
foreach ($terms as $type => $v) {
$terms[$type] = (object) array(
'vid' => $this->vocabulary->vid,
'name' => $this
->randomName(),
);
taxonomy_term_save($terms[$type]);
$nodes[$type] = (object) array(
'type' => $this->content_type,
'title' => $this
->randomName(),
$this->field['field_name'] => array(
LANGUAGE_NONE => array(
array(
'target_id' => $terms[$type]->tid,
),
),
),
);
node_save($nodes[$type]);
}
actions_do('term_merge_action', $terms['branch'], array(
'term_trunk' => $terms['trunk']->tid,
'term_branch_keep' => FALSE,
));
foreach ($nodes as $type => $node) {
$node = entity_load_unchanged('node', $node->nid);
$this
->assertEqual($terms['trunk']->tid, $node->{$this->field['field_name']}[LANGUAGE_NONE][0]['target_id'], $type . ' node points to trunk term in the entity reference field after merging the terms.');
}
}