You are here

protected function TaxonomyViewsIntegratorTestBase::createTerm in Taxonomy Views Integrator 8

Creates and returns a taxonomy term.

Borrowed from TaxonomyTestBase.

Parameters

array $settings: (optional) An array of values to override the following default properties of the term:

  • name: A random string.
  • description: A random string.
  • format: First available text format.
  • vid: Vocabulary ID of self::$vocabulary object.
  • langcode: LANGCODE_NOT_SPECIFIED.

Defaults to an empty array.

Return value

\Drupal\taxonomy\Entity\Term The created taxonomy term.

1 call to TaxonomyViewsIntegratorTestBase::createTerm()
TaxonomyViewsIntegratorTestBase::setUp in tests/src/Functional/TaxonomyViewsIntegratorTestBase.php

File

tests/src/Functional/TaxonomyViewsIntegratorTestBase.php, line 269

Class

TaxonomyViewsIntegratorTestBase
TVI PHPUnit Test base.

Namespace

Drupal\Tests\tvi\Functional

Code

protected function createTerm(array $settings = []) {
  $filter_formats = filter_formats();
  $format = array_pop($filter_formats);
  $settings += [
    'name' => $this
      ->randomMachineName(),
    'description' => $this
      ->randomMachineName(),
    // Use the first available text format.
    'format' => $format
      ->id(),
    'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
  ];
  $term = Term::create($settings);
  $term
    ->save();
  return $term;
}