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 148
Definition of Drupal\views\Tests\DefaultViewsTest.

Class

DefaultViewsTest
Tests for views default views.

Namespace

Drupal\views\Tests

Code

function createTerm($vocabulary) {
  $filter_formats = filter_formats();
  $format = array_pop($filter_formats);
  $term = entity_create('taxonomy_term', array(
    'name' => $this
      ->randomName(),
    'description' => $this
      ->randomName(),
    // Use the first available text format.
    'format' => $format->format,
    'vid' => $vocabulary
      ->id(),
    'langcode' => Language::LANGCODE_NOT_SPECIFIED,
  ));
  $term
    ->save();
  return $term;
}