You are here

protected function BambooTwigI18nTest::setUpTags in Bamboo Twig 8.3

Setup default taxonomy vocabulary with terms for testing.

1 call to BambooTwigI18nTest::setUpTags()
BambooTwigI18nTest::setUp in tests/src/Functional/BambooTwigI18nTest.php

File

tests/src/Functional/BambooTwigI18nTest.php, line 113

Class

BambooTwigI18nTest
Tests I18n twig filters and functions.

Namespace

Drupal\Tests\bamboo_twig\Functional

Code

protected function setUpTags() {

  // Create a taxonomy vocabulary that we will use for testing.
  $this->entityTypeManager
    ->getStorage('taxonomy_vocabulary')
    ->create([
    'vid' => 'tags',
    'name' => 'Tags',
  ])
    ->save();

  // Add tests tags.
  $this->tags = [];
  $tag = $this->entityTypeManager
    ->getStorage('taxonomy_term')
    ->create([
    'name' => 'Tags N°1',
    'vid' => 'tags',
  ]);
  $tag
    ->save();
  $this->tags[] = $tag;
  $tag = $this->entityTypeManager
    ->getStorage('taxonomy_term')
    ->create([
    'name' => 'Tags N°2',
    'vid' => 'tags',
  ]);
  $tag
    ->save();
  $tag_translation = $tag
    ->addTranslation('fr', $tag
    ->toArray());
  $tag_translation->title = 'Mot clé N°2';
  $tag_translation
    ->save();
  $this->tags[] = $tag;
  $tag = $this->entityTypeManager
    ->getStorage('taxonomy_term')
    ->create([
    'name' => 'Tags N°3',
    'vid' => 'tags',
  ]);
  $tag
    ->save();
  $tag_translation = $tag
    ->addTranslation('fr', $tag
    ->toArray());
  $tag_translation->title = 'Mot clé N°3';
  $tag_translation
    ->save();
  $tag_translation = $tag
    ->addTranslation('de', $tag
    ->toArray());
  $tag_translation->title = 'Stichworte N°3';
  $tag_translation
    ->save();
  $this->tags[] = $tag;
}