You are here

function EntityTest::addTerm in Token 8

1 call to EntityTest::addTerm()
EntityTest::testEntityMapping in tests/src/Kernel/EntityTest.php

File

tests/src/Kernel/EntityTest.php, line 67

Class

EntityTest
Tests entity tokens.

Namespace

Drupal\Tests\token\Kernel

Code

function addTerm(VocabularyInterface $vocabulary, array $term = []) {
  $term += [
    'name' => mb_strtolower($this
      ->randomMachineName(5)),
    'vid' => $vocabulary
      ->id(),
  ];
  $term = Term::create($term);
  $term
    ->save();
  return $term;
}