function QuickEditAutocompleteTermTest::createTerm

Same name and namespace in other branches
  1. 9 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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.