You are here

protected function TaxonomyTestBase::createTerm in Zircon Profile 8

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

Returns a new term with random properties in vocabulary $vid.

Parameters

array $settings: (Optional) An associative array of settings to pass to `entity_create`.

Return value

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

5 calls to TaxonomyTestBase::createTerm()
ArgumentValidatorTermTest::setUp in core/modules/taxonomy/src/Tests/Views/ArgumentValidatorTermTest.php
Sets up a Drupal site for running functional and integration tests.
TaxonomyTermArgumentDepthTest::setUp in core/modules/taxonomy/src/Tests/Views/TaxonomyTermArgumentDepthTest.php
Sets up a Drupal site for running functional and integration tests.
TaxonomyTermFilterDepthTest::setUp in core/modules/taxonomy/src/Tests/Views/TaxonomyTermFilterDepthTest.php
Sets up a Drupal site for running functional and integration tests.
TaxonomyTermViewTest::testTaxonomyTermView in core/modules/taxonomy/src/Tests/Views/TaxonomyTermViewTest.php
Tests that the taxonomy term view is working properly.
TaxonomyTestBase::setUp in core/modules/taxonomy/src/Tests/Views/TaxonomyTestBase.php
Sets up a Drupal site for running functional and integration tests.

File

core/modules/taxonomy/src/Tests/Views/TaxonomyTestBase.php, line 130
Contains \Drupal\taxonomy\Tests\Views\TaxonomyTestBase.

Class

TaxonomyTestBase
Base class for all taxonomy tests.

Namespace

Drupal\taxonomy\Tests\Views

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(),
    'vid' => $this->vocabulary
      ->id(),
    'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
  ];
  $term = entity_create('taxonomy_term', $settings);
  $term
    ->save();
  return $term;
}