public function DefaultViewsTest::createTerm in Drupal 8
Same name and namespace in other branches
- 9 core/modules/views/tests/src/Functional/DefaultViewsTest.php \Drupal\Tests\views\Functional\DefaultViewsTest::createTerm()
Returns a new term with random properties in vocabulary $vid.
1 call to DefaultViewsTest::createTerm()
- DefaultViewsTest::setUp in core/
modules/ views/ tests/ src/ Functional/ DefaultViewsTest.php
File
- core/
modules/ views/ tests/ src/ Functional/ DefaultViewsTest.php, line 169
Class
- DefaultViewsTest
- Tests the default views provided by views.
Namespace
Drupal\Tests\views\FunctionalCode
public function createTerm($vocabulary) {
$filter_formats = filter_formats();
$format = array_pop($filter_formats);
$term = Term::create([
'name' => $this
->randomMachineName(),
'description' => $this
->randomMachineName(),
// Use the first available text format.
'format' => $format
->id(),
'vid' => $vocabulary
->id(),
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
]);
$term
->save();
return $term;
}