private function TermMatcherTest::createVocabulary in Linkit 8.5
Creates and saves a vocabulary.
Parameters
string $name: The vocabulary name.
Return value
\Drupal\Core\Entity\EntityInterface|\Drupal\taxonomy\VocabularyInterface The new vocabulary object.
1 call to TermMatcherTest::createVocabulary()
- TermMatcherTest::setUp in tests/
src/ Kernel/ Matchers/ TermMatcherTest.php
File
- tests/
src/ Kernel/ Matchers/ TermMatcherTest.php, line 115
Class
- TermMatcherTest
- Tests term matcher.
Namespace
Drupal\Tests\linkit\Kernel\MatchersCode
private function createVocabulary($name) {
$vocabularyStorage = \Drupal::entityTypeManager()
->getStorage('taxonomy_vocabulary');
$vocabulary = $vocabularyStorage
->create([
'name' => $name,
'description' => $name,
'vid' => mb_strtolower($name),
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
]);
$vocabulary
->save();
return $vocabulary;
}