function DefaultViewsTest::createTerm

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

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

File

drupal/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php, line 151
Definition of Drupal\views\Tests\DefaultViewsTest.

Class

DefaultViewsTest
Tests for views default views.

Namespace

Drupal\views\Tests

Code

function createTerm($vocabulary) {
  $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' => $vocabulary->vid,
    'langcode' => LANGUAGE_NOT_SPECIFIED,
  ));
  taxonomy_term_save($term);
  return $term;
}