You are here

protected function TaxonomyTestBase::createTerm in Views (for Drupal 7) 8.3

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

Return value

Drupal\taxonomy\Term The created taxonomy term.

1 call to TaxonomyTestBase::createTerm()
TaxonomyTestBase::setUp in lib/Drupal/views/Tests/Taxonomy/TaxonomyTestBase.php
Sets up a Drupal site for running functional and integration tests.

File

lib/Drupal/views/Tests/Taxonomy/TaxonomyTestBase.php, line 124
Definition of Drupal\views\Tests\Taxonomy\TaxonomyTestBase.

Class

TaxonomyTestBase
Base class for all taxonomy tests.

Namespace

Drupal\views\Tests\Taxonomy

Code

protected function createTerm() {
  $term = entity_create('taxonomy_term', array(
    'name' => $this
      ->randomName(),
    'description' => $this
      ->randomName(),
    // Use the first available text format.
    'format' => db_query_range('SELECT format FROM {filter_format}', 0, 1)
      ->fetchField(),
    'vid' => $this->vocabulary->vid,
    'langcode' => LANGUAGE_NOT_SPECIFIED,
  ));
  $term
    ->save();
  return $term;
}