protected function ArgumentValidatorTermNameTest::setUp in Drupal 10
Parameters
bool $import_test_views: Should the views specified on the test class be imported. If you need to setup some additional stuff, like fields, you need to call false and then call createTestViews for your own.
Overrides TaxonomyTestBase::setUp
File
- core/
modules/ taxonomy/ tests/ src/ Kernel/ Views/ ArgumentValidatorTermNameTest.php, line 44
Class
- ArgumentValidatorTermNameTest
- Tests the plugin of the taxonomy: taxonomy_term_name argument validator.
Namespace
Drupal\Tests\taxonomy\Kernel\ViewsCode
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();
}