function TaxonomyIndexTidUiTest::setUp

Same name in other branches
  1. 8.9.x core/modules/taxonomy/tests/src/Functional/Views/TaxonomyIndexTidUiTest.php \Drupal\Tests\taxonomy\Functional\Views\TaxonomyIndexTidUiTest::setUp()
  2. 10 core/modules/taxonomy/tests/src/Functional/Views/TaxonomyIndexTidUiTest.php \Drupal\Tests\taxonomy\Functional\Views\TaxonomyIndexTidUiTest::setUp()
  3. 11.x 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 61

Class

TaxonomyIndexTidUiTest
Tests the taxonomy index filter handler UI.

Namespace

Drupal\Tests\taxonomy\Functional\Views

Code

protected function setUp($import_test_views = TRUE, $modules = []) : void {
    parent::setUp($import_test_views, $modules);
    $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();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.