function ArgumentValidatorTermNameTest::setUp

Same name and namespace in other branches
  1. 9 core/modules/taxonomy/tests/src/Kernel/Views/ArgumentValidatorTermNameTest.php \Drupal\Tests\taxonomy\Kernel\Views\ArgumentValidatorTermNameTest::setUp()
  2. 11.x core/modules/taxonomy/tests/src/Kernel/Views/ArgumentValidatorTermNameTest.php \Drupal\Tests\taxonomy\Kernel\Views\ArgumentValidatorTermNameTest::setUp()

Overrides TaxonomyTestBase::setUp

File

core/modules/taxonomy/tests/src/Kernel/Views/ArgumentValidatorTermNameTest.php, line 46

Class

ArgumentValidatorTermNameTest
Tests the plugin of the taxonomy: taxonomy_term_name argument validator.

Namespace

Drupal\Tests\taxonomy\Kernel\Views

Code

protected function setUp($import_test_views = TRUE) : void {
  parent::setUp($import_test_views);
  // 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();
  }
  // Create a second vocabulary.
  $vocabulary2 = Vocabulary::create([
    'name' => 'Views testing tags 2',
    'vid' => 'views_testing_tags_2',
  ]);
  $vocabulary2->save();
  // Add term in this vocabulary that has same name as term 3.
  $duplicate = $this->createTerm([
    'name' => $this->names[2],
    'vid' => 'views_testing_tags_2',
  ]);
  $this->terms[] = $duplicate;
  $this->names[] = $duplicate->label();
  $this->ids[] = $duplicate->id();
  // Add uniquely named term in second vocab as well.
  $unique = $this->createTerm([
    'vid' => 'views_testing_tags_2',
  ]);
  $this->terms[] = $unique;
  $this->names[] = $unique->label();
  $this->ids[] = $unique->id();
}

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