protected function TaxonomyFieldFilterTest::createTermWithProperties in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/taxonomy/src/Tests/Views/TaxonomyFieldFilterTest.php \Drupal\taxonomy\Tests\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/ src/ Tests/ Views/ TaxonomyFieldFilterTest.php - Sets up a Drupal site for running functional and integration tests.
File
- core/
modules/ taxonomy/ src/ Tests/ Views/ TaxonomyFieldFilterTest.php, line 162 - Contains \Drupal\taxonomy\Tests\Views\TaxonomyFieldFilterTest.
Class
- TaxonomyFieldFilterTest
- Tests taxonomy field filters with translations.
Namespace
Drupal\taxonomy\Tests\ViewsCode
protected function createTermWithProperties($properties) {
// Use the first available text format.
$filter_formats = filter_formats();
$format = array_pop($filter_formats);
$properties += array(
'name' => $this
->randomMachineName(),
'description' => $this
->randomMachineName(),
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
'field_foo' => $this
->randomMachineName(),
);
$term = entity_create('taxonomy_term', array(
'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;
}