You are here

function DefaultViewsTest::createTerm in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/src/Tests/DefaultViewsTest.php \Drupal\views\Tests\DefaultViewsTest::createTerm()

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

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

File

core/modules/views/src/Tests/DefaultViewsTest.php, line 148
Contains \Drupal\views\Tests\DefaultViewsTest.

Class

DefaultViewsTest
Tests the default views provided by 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
      ->randomMachineName(),
    'description' => $this
      ->randomMachineName(),
    // Use the first available text format.
    'format' => $format
      ->id(),
    'vid' => $vocabulary
      ->id(),
    'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
  ));
  $term
    ->save();
  return $term;
}