protected function AddHierarchyTest::createTaxonomyHierarchy in Search API 8
Helper function to create the hierarchy with taxonomy terms.
1 call to AddHierarchyTest::createTaxonomyHierarchy()
- AddHierarchyTest::setUp in tests/
src/ Kernel/ Processor/ AddHierarchyTest.php - Performs setup tasks before each individual test method is run.
File
- tests/
src/ Kernel/ Processor/ AddHierarchyTest.php, line 159
Class
- AddHierarchyTest
- Tests the "Hierarchy" processor.
Namespace
Drupal\Tests\search_api\Kernel\ProcessorCode
protected function createTaxonomyHierarchy() {
$this->vocabulary = $this
->createVocabulary();
foreach (static::$hierarchy as $type => $items) {
// Add the 'type' item, and nest items underneath.
$this->terms[$type] = $type_term = $this
->createTerm($this->vocabulary, [
'name' => $type,
]);
foreach ($items as $item) {
$this->terms["{$type}.{$item}"] = $this
->createTerm($this->vocabulary, [
'name' => $item,
'parent' => $type_term,
]);
}
}
}