protected function setUp() { parent::setUp(); // Add three terms to the 'tags' vocabulary. for ($i = 0; $i < 3; $i++) { $this->terms[] = $term = $this->createTerm(); $this->names[] = $term->label(); $this->ids[] = $term->id(); } }
/** * {@inheritdoc} */ protected function setUp() { parent::setUp(); // Create an administrative user. $this->adminUser = $this->drupalCreateUser(['administer taxonomy', 'bypass node access']); $this->drupalLogin($this->adminUser); // Create a vocabulary and add two term reference fields to article nodes. $this->fieldName1 = Unicode::strtolower($this->randomMachineName()); $handler_settings = array('target_bundles' => array($this->vocabulary->id() => $this->vocabulary->id()), 'auto_create' => TRUE); $this->createEntityReferenceField('node', 'article', $this->fieldName1, NULL, 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED); entity_get_form_display('node', 'article', 'default')->setComponent($this->fieldName1, array('type' => 'options_select'))->save(); entity_get_display('node', 'article', 'default')->setComponent($this->fieldName1, array('type' => 'entity_reference_label'))->save(); }
/** * {@inheritdoc} */ protected function setUp() { parent::setUp(); // Create an administrative user. $this->adminUser = $this->drupalCreateUser(['administer taxonomy', 'bypass node access']); $this->drupalLogin($this->adminUser); // Create a vocabulary and add two term reference fields to article nodes. $this->fieldName1 = Unicode::strtolower($this->randomMachineName()); entity_create('field_storage_config', array('field_name' => $this->fieldName1, 'entity_type' => 'node', 'type' => 'taxonomy_term_reference', 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED, 'settings' => array('allowed_values' => array(array('vocabulary' => $this->vocabulary->id(), 'parent' => 0)))))->save(); entity_create('field_config', array('field_name' => $this->fieldName1, 'bundle' => 'article', 'entity_type' => 'node'))->save(); entity_get_form_display('node', 'article', 'default')->setComponent($this->fieldName1, array('type' => 'options_select'))->save(); entity_get_display('node', 'article', 'default')->setComponent($this->fieldName1, array('type' => 'taxonomy_term_reference_link'))->save(); }
/** * {@inheritdoc} */ protected function setUp() { parent::setUp(FALSE); // Setup vocabulary and terms so the initial import is valid. Vocabulary::create(['vid' => 'tags', 'name' => 'Tags'])->save(); // This will get a term ID of 3. $term = Term::create(['vid' => 'tags', 'name' => 'muh']); $term->save(); // This will get a term ID of 4. $this->terms[$term->id()] = $term; $term = Term::create(['vid' => 'tags', 'name' => 'muh']); $term->save(); $this->terms[$term->id()] = $term; ViewTestData::createTestViews(get_class($this), array('taxonomy_test_views')); }
/** * {@inheritdoc} */ protected function setUp() { parent::setUp(); // Make term2 parent of term1. $this->term1->set('parent', $this->term2->id()); $this->term1->save(); // Store terms in an array for testing. $this->terms[] = $this->term1; $this->terms[] = $this->term2; // Only set term1 on node1 and term2 on node2 for testing. unset($this->nodes[0]->field_views_testing_tags[1]); $this->nodes[0]->save(); unset($this->nodes[1]->field_views_testing_tags[0]); $this->nodes[1]->save(); Views::viewsData()->clear(); }
/** * {@inheritdoc} */ public function setUp() { parent::setUp(); // Create a hierarchy 3 deep. Note the parent setup function creates two // top-level terms w/o children. $first = $this->createTerm(['name' => 'First']); $second = $this->createTerm(['name' => 'Second', 'parent' => $first->id()]); $third = $this->createTerm(['name' => 'Third', 'parent' => $second->id()]); // Create a node w/o any terms. $settings = ['type' => 'article']; $this->nodes[] = $this->drupalCreateNode($settings); // Create a node with only the top level term. $settings['field_views_testing_tags'][0]['target_id'] = $first->id(); $this->nodes[] = $this->drupalCreateNode($settings); // Create a node with only the third level term. $settings['field_views_testing_tags'][0]['target_id'] = $third->id(); $this->nodes[] = $this->drupalCreateNode($settings); $this->terms[0] = $first; $this->terms[1] = $second; $this->terms[2] = $third; $this->view = Views::getView('test_filter_taxonomy_index_tid_depth'); }