You are here

protected function TermTranslationTest::setUpTerms in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/taxonomy/tests/src/Functional/TermTranslationTest.php \Drupal\Tests\taxonomy\Functional\TermTranslationTest::setUpTerms()
  2. 10 core/modules/taxonomy/tests/src/Functional/TermTranslationTest.php \Drupal\Tests\taxonomy\Functional\TermTranslationTest::setUpTerms()

Setup translated terms in a hierarchy.

1 call to TermTranslationTest::setUpTerms()
TermTranslationTest::setUp in core/modules/taxonomy/tests/src/Functional/TermTranslationTest.php

File

core/modules/taxonomy/tests/src/Functional/TermTranslationTest.php, line 123

Class

TermTranslationTest
Tests for proper breadcrumb translation.

Namespace

Drupal\Tests\taxonomy\Functional

Code

protected function setUpTerms() {
  $parent_vid = 0;
  foreach ($this->termTranslationMap as $name => $translation) {
    $term = $this
      ->createTerm($this->vocabulary, [
      'name' => $name,
      'langcode' => $this->baseLangcode,
      'parent' => $parent_vid,
    ]);
    $term
      ->addTranslation($this->translateToLangcode, [
      'name' => $translation,
    ]);
    $term
      ->save();

    // Each term is nested under the last.
    $parent_vid = $term
      ->id();
    $this->terms[] = $term;
  }
}