1 entityreference.taxonomy.test | public EntityReferenceTaxonomyTestCase::testNodeIndex() |
Test referencing a term using entity reference field.
File
- core/
modules/ entityreference/ tests/ entityreference.taxonomy.test, line 87
Class
- EntityReferenceTaxonomyTestCase
- Test for Entity Reference taxonomy integration.
Code
public function testNodeIndex() {
$this->setupForIndex();
$langcode = LANGUAGE_NONE;
// Assert node insert with reference to term.
$settings = array();
$settings['type'] = 'post';
$settings['field_entityreference_term'][LANGUAGE_NONE][0]['target_id'] = 1;
$node = $this->backdropCreateNode($settings);
$this->assertEqual(taxonomy_select_nodes(1), array($node->nid));
// Assert node update with reference to term.
node_save($node);
$this->assertEqual(taxonomy_select_nodes(1), array($node->nid));
// Assert node update with reference to term and taxonomy reference to
// another term.
$node->field_taxonomy_term[$langcode] = array(array('tid' => 2));
$node->save();
$this->assertEqual(taxonomy_select_nodes(1), array($node->nid));
$this->assertEqual(taxonomy_select_nodes(2), array($node->nid));
// Assert node update with reference to term and taxonomy reference to
// same term.
$node->field_taxonomy_term[$langcode] = array(array('tid' => 1));
$node->save();
$this->assertEqual(taxonomy_select_nodes(1), array($node->nid));
$node->delete();
$this->assertFalse(taxonomy_select_nodes(1));
}