function TermTranslationTest::setUpTerms

Same name in other branches
  1. 9 core/modules/taxonomy/tests/src/Functional/TermTranslationTest.php \Drupal\Tests\taxonomy\Functional\TermTranslationTest::setUpTerms()
  2. 8.9.x core/modules/taxonomy/tests/src/Functional/TermTranslationTest.php \Drupal\Tests\taxonomy\Functional\TermTranslationTest::setUpTerms()
  3. 11.x 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 125

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;
    }
}

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