You are here

protected function TaxonomyEntityIndexTermFilterDepthTest::setUp in Taxonomy Entity Index 8

Overrides TaxonomyEntityIndexTestBase::setUp

File

tests/src/Functional/Views/TaxonomyEntityIndexTermFilterDepthTest.php, line 53

Class

TaxonomyEntityIndexTermFilterDepthTest
Test the taxonomy term with depth filter.

Namespace

Drupal\Tests\taxonomy_entity_index\Functional\Views

Code

protected function setUp($import_test_views = TRUE) {
  parent::setUp($import_test_views);

  // 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_entity_index_index_tid_depth');
}