function TaxonomyFieldFilterTest::createTermWithProperties
Same name in other branches
- 9 core/modules/taxonomy/tests/src/Functional/Views/TaxonomyFieldFilterTest.php \Drupal\Tests\taxonomy\Functional\Views\TaxonomyFieldFilterTest::createTermWithProperties()
- 10 core/modules/taxonomy/tests/src/Functional/Views/TaxonomyFieldFilterTest.php \Drupal\Tests\taxonomy\Functional\Views\TaxonomyFieldFilterTest::createTermWithProperties()
- 11.x core/modules/taxonomy/tests/src/Functional/Views/TaxonomyFieldFilterTest.php \Drupal\Tests\taxonomy\Functional\Views\TaxonomyFieldFilterTest::createTermWithProperties()
Creates a taxonomy term with specified name and other properties.
Parameters
array $properties: Array of properties and field values to set.
Return value
\Drupal\taxonomy\TermInterface The created taxonomy term.
1 call to TaxonomyFieldFilterTest::createTermWithProperties()
- TaxonomyFieldFilterTest::setUp in core/
modules/ taxonomy/ tests/ src/ Functional/ Views/ TaxonomyFieldFilterTest.php
File
-
core/
modules/ taxonomy/ tests/ src/ Functional/ Views/ TaxonomyFieldFilterTest.php, line 173
Class
- TaxonomyFieldFilterTest
- Tests taxonomy field filters with translations.
Namespace
Drupal\Tests\taxonomy\Functional\ViewsCode
protected function createTermWithProperties($properties) {
// Use the first available text format.
$filter_formats = filter_formats();
$format = array_pop($filter_formats);
$properties += [
'name' => $this->randomMachineName(),
'description' => $this->randomMachineName(),
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
'field_foo' => $this->randomMachineName(),
];
$term = Term::create([
'name' => $properties['name'],
'description' => $properties['description'],
'format' => $format->id(),
'vid' => $this->vocabulary
->id(),
'langcode' => $properties['langcode'],
]);
$term->field_foo->value = $properties['field_foo'];
$term->save();
return $term;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.