You are here

protected function TaxonomyIndexTidUiTest::setUp in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/taxonomy/tests/src/Functional/Views/TaxonomyIndexTidUiTest.php \Drupal\Tests\taxonomy\Functional\Views\TaxonomyIndexTidUiTest::setUp()

Overrides UITestBase::setUp

File

core/modules/taxonomy/tests/src/Functional/Views/TaxonomyIndexTidUiTest.php, line 57

Class

TaxonomyIndexTidUiTest
Tests the taxonomy index filter handler UI.

Namespace

Drupal\Tests\taxonomy\Functional\Views

Code

protected function setUp($import_test_views = TRUE) : void {
  parent::setUp($import_test_views);
  $this->adminUser = $this
    ->drupalCreateUser([
    'administer taxonomy',
    'administer views',
  ]);
  $this
    ->drupalLogin($this->adminUser);
  Vocabulary::create([
    'vid' => 'tags',
    'name' => 'Tags',
  ])
    ->save();

  // Setup a hierarchy which looks like this:
  // term 0.0
  // term 1.0
  // - term 1.1
  // term 2.0
  // - term 2.1
  // - term 2.2
  for ($i = 0; $i < 3; $i++) {
    for ($j = 0; $j <= $i; $j++) {
      $this->terms[$i][$j] = $term = Term::create([
        'vid' => 'tags',
        'name' => "Term {$i}.{$j}",
        'parent' => isset($this->terms[$i][0]) ? $this->terms[$i][0]
          ->id() : 0,
      ]);
      $term
        ->save();
    }
  }
  ViewTestData::createTestViews(static::class, [
    'taxonomy_test_views',
  ]);
  Vocabulary::create([
    'vid' => 'empty_vocabulary',
    'name' => 'Empty Vocabulary',
  ])
    ->save();
}