You are here

protected function QuickEditAutocompleteTermTest::createTerm in Drupal 9

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

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

Return value

\Drupal\Core\Entity\EntityInterface|\Drupal\taxonomy\Entity\Term The created taxonomy term.

Throws

\Drupal\Core\Entity\EntityStorageException

1 call to QuickEditAutocompleteTermTest::createTerm()
QuickEditAutocompleteTermTest::setUp in core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditAutocompleteTermTest.php

File

core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditAutocompleteTermTest.php, line 194

Class

QuickEditAutocompleteTermTest
Tests in-place editing of autocomplete tags.

Namespace

Drupal\Tests\quickedit\FunctionalJavascript

Code

protected function createTerm() {
  $filter_formats = filter_formats();
  $format = array_pop($filter_formats);
  $term = Term::create([
    '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;
}