function DefaultViewsTest::createTerm
Same name in other branches
- 9 core/modules/views/tests/src/Functional/DefaultViewsTest.php \Drupal\Tests\views\Functional\DefaultViewsTest::createTerm()
- 8.9.x core/modules/views/tests/src/Functional/DefaultViewsTest.php \Drupal\Tests\views\Functional\DefaultViewsTest::createTerm()
- 10 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 - Sets up the test.
File
-
core/
modules/ views/ tests/ src/ Functional/ DefaultViewsTest.php, line 168
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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.