You are here

public function TaxonomyTermFilterDepthTest::setUp in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/taxonomy/src/Tests/Views/TaxonomyTermFilterDepthTest.php \Drupal\taxonomy\Tests\Views\TaxonomyTermFilterDepthTest::setUp()

Sets up a Drupal site for running functional and integration tests.

Installs Drupal with the installation profile specified in \Drupal\simpletest\WebTestBase::$profile into the prefixed database.

Afterwards, installs any additional modules specified in the static \Drupal\simpletest\WebTestBase::$modules property of each class in the class hierarchy.

After installation all caches are flushed and several configuration values are reset to the values of the parent site executing the test, since the default values may be incompatible with the environment in which tests are being executed.

Overrides TaxonomyTestBase::setUp

File

core/modules/taxonomy/src/Tests/Views/TaxonomyTermFilterDepthTest.php, line 42
Contains \Drupal\taxonomy\Tests\Views\TaxonomyTermFilterDepthTest.

Class

TaxonomyTermFilterDepthTest
Test the taxonomy term with depth filter.

Namespace

Drupal\taxonomy\Tests\Views

Code

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