You are here

protected function QuickEditAutocompleteTermTest::createTerm in Zircon Profile 8

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

Returns a new term with random name and description in $this->vocabulary.

Return value

\Drupal\taxonomy\TermInterface The created taxonomy term.

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

File

core/modules/quickedit/src/Tests/QuickEditAutocompleteTermTest.php, line 202
Contains \Drupal\quickedit\Tests\QuickEditAutocompleteTermTest.

Class

QuickEditAutocompleteTermTest
Tests in-place editing of autocomplete tags.

Namespace

Drupal\quickedit\Tests

Code

protected function createTerm() {
  $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' => $this->vocabulary
      ->id(),
    'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
  ));
  $term
    ->save();
  return $term;
}