function TaxonomyTestBase::createTerm
Same name in this branch
- 9 core/modules/taxonomy/tests/src/Functional/Views/TaxonomyTestBase.php \Drupal\Tests\taxonomy\Functional\Views\TaxonomyTestBase::createTerm()
Same name in other branches
- 8.9.x core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyTestBase.php \Drupal\Tests\taxonomy\Kernel\Views\TaxonomyTestBase::createTerm()
- 8.9.x core/modules/taxonomy/tests/src/Functional/Views/TaxonomyTestBase.php \Drupal\Tests\taxonomy\Functional\Views\TaxonomyTestBase::createTerm()
- 10 core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyTestBase.php \Drupal\Tests\taxonomy\Kernel\Views\TaxonomyTestBase::createTerm()
- 10 core/modules/taxonomy/tests/src/Functional/Views/TaxonomyTestBase.php \Drupal\Tests\taxonomy\Functional\Views\TaxonomyTestBase::createTerm()
- 11.x core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyTestBase.php \Drupal\Tests\taxonomy\Kernel\Views\TaxonomyTestBase::createTerm()
- 11.x core/modules/taxonomy/tests/src/Functional/Views/TaxonomyTestBase.php \Drupal\Tests\taxonomy\Functional\Views\TaxonomyTestBase::createTerm()
Creates and returns a taxonomy term.
Parameters
array $settings: (optional) An array of values to override the following default properties of the term:
- name: A random string.
- description: A random string.
- format: First available text format.
- vid: Vocabulary ID of self::$vocabulary object.
- langcode: LANGCODE_NOT_SPECIFIED.
Defaults to an empty array.
Return value
\Drupal\taxonomy\Entity\Term The created taxonomy term.
6 calls to TaxonomyTestBase::createTerm()
- ArgumentTransformTermTest::testTermArgumentTransformation in core/
modules/ taxonomy/ tests/ src/ Kernel/ Views/ ArgumentTransformTermTest.php - Tests term argument transformation of hyphens and spaces.
- ArgumentValidatorTermNameTest::setUp in core/
modules/ taxonomy/ tests/ src/ Kernel/ Views/ ArgumentValidatorTermNameTest.php - ArgumentValidatorTermTest::setUp in core/
modules/ taxonomy/ tests/ src/ Kernel/ Views/ ArgumentValidatorTermTest.php - TaxonomyTermArgumentDepthTest::setUp in core/
modules/ taxonomy/ tests/ src/ Kernel/ Views/ TaxonomyTermArgumentDepthTest.php - TaxonomyTermFilterDepthTest::setUp in core/
modules/ taxonomy/ tests/ src/ Kernel/ Views/ TaxonomyTermFilterDepthTest.php
File
-
core/
modules/ taxonomy/ tests/ src/ Kernel/ Views/ TaxonomyTestBase.php, line 171
Class
- TaxonomyTestBase
- Base class for views kernel taxonomy tests.
Namespace
Drupal\Tests\taxonomy\Kernel\ViewsCode
protected function createTerm(array $settings = []) {
$filter_formats = filter_formats();
$format = array_pop($filter_formats);
$settings += [
'name' => $this->randomMachineName(),
'description' => $this->randomMachineName(),
// Use the first available text format.
'format' => $format->id(),
'vid' => $this->vocabulary
->id(),
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
];
$term = Term::create($settings);
$term->save();
return $term;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.