protected function ShsTestTrait::createTerms in Simple hierarchical select 2.0.x
Create terms for use in tests.
1 call to ShsTestTrait::createTerms()
- ShsTestTrait::prepareSetup in tests/
src/ Functional/ ShsTestTrait.php - Prepares test setup by creating a content type with the necessary fields.
File
- tests/
src/ Functional/ ShsTestTrait.php, line 98
Class
- ShsTestTrait
- Base test class for SHS browser tests.
Namespace
Drupal\Tests\shs\FunctionalCode
protected function createTerms() : void {
$this->termIds = [];
$terms = $this
->getTermStructure();
foreach ($terms as $name => $parent) {
$values = [
'name' => $name,
];
if (!empty($parent) && isset($this->termIds[$parent])) {
$values['parent'] = $this->termIds[$parent];
}
$term = $this
->createTerm($this->vocabulary, $values);
$this->termIds[$name] = $term
->id();
}
}