trait TaxonomyTestTrait (View source)

deprecated in drupal:8.4.0 and is removed from drupal:9.0.0. Use \Drupal\Tests\taxonomy\Traits\TaxonomyTestTrait instead.

Provides common helper methods for Taxonomy module tests.

Methods

createVocabulary()

Returns a new vocabulary with random properties.

createTerm(Vocabulary $vocabulary, array $values = [])

Returns a new term with random properties in vocabulary $vid.

Details

createVocabulary()

Returns a new vocabulary with random properties.

Term createTerm(Vocabulary $vocabulary, array $values = [])

Returns a new term with random properties in vocabulary $vid.

Parameters

Vocabulary $vocabulary

The vocabulary object.

array $values

(optional) An array of values to set, keyed by property name. If the entity type has bundles, the bundle key has to be specified.

Return Value

Term

The new taxonomy term object.