protected function BambooTwigTestBase::setUpTags in Bamboo Twig 8.5
Same name and namespace in other branches
- 8.4 tests/src/Functional/BambooTwigTestBase.php \Drupal\Tests\bamboo_twig\Functional\BambooTwigTestBase::setUpTags()
Setup default taxonomy vocabulary with terms for testing.
Summary: | Tid | Name | EN | DE | FR | |-----|---------|--------------|----| -------------| | 1 | Tag N°1 | X (original) | | | | 2 | Tag N°2 | X (original) | | X | | 3 | Tag N°3 | X (original) | X | X | | 4 | Tag N°4 | | | X (original) | | 5 | Tag N°5 | X | | X (original) |
4 calls to BambooTwigTestBase::setUpTags()
- BambooTwigI18nTest::setUp in tests/
src/ Functional/ BambooTwigI18nTest.php - BambooTwigLoaderTest::setUp in tests/
src/ Functional/ BambooTwigLoaderTest.php - BambooTwigRenderTest::setUp in tests/
src/ Functional/ BambooTwigRenderTest.php - BambooTwigTokenTest::setUp in tests/
src/ Functional/ BambooTwigTokenTest.php
File
- tests/
src/ Functional/ BambooTwigTestBase.php, line 177
Class
- BambooTwigTestBase
- Has some additional helper methods to make test code more readable.
Namespace
Drupal\Tests\bamboo_twig\FunctionalCode
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' => 'Tag N°1',
'vid' => 'tags',
]);
$tag
->save();
$this->tags[] = $tag;
$tag = $this->entityTypeManager
->getStorage('taxonomy_term')
->create([
'name' => 'Tag N°2',
'vid' => 'tags',
]);
$tag
->save();
$tag_translation = $tag
->addTranslation('fr', $tag
->toArray());
$tag_translation->name = 'Mot clé N°2';
$tag_translation
->save();
$this->tags[] = $tag;
$tag = $this->entityTypeManager
->getStorage('taxonomy_term')
->create([
'name' => 'Tag N°3',
'vid' => 'tags',
]);
$tag
->save();
$tag_translation = $tag
->addTranslation('fr', $tag
->toArray());
$tag_translation->name = 'Mot clé N°3';
$tag_translation
->save();
$tag_translation = $tag
->addTranslation('de', $tag
->toArray());
$tag_translation->name = 'Stichworte N°3';
$tag_translation
->save();
$this->tags[] = $tag;
$tag = $this->entityTypeManager
->getStorage('taxonomy_term')
->create([
'name' => 'Mot clé N°4',
'vid' => 'tags',
'langcode' => 'fr',
]);
$tag
->save();
$this->tags[] = $tag;
$tag = $this->entityTypeManager
->getStorage('taxonomy_term')
->create([
'name' => 'Mot clé N°5',
'vid' => 'tags',
'langcode' => 'fr',
]);
$tag
->save();
$tag_translation = $tag
->addTranslation('en', $tag
->toArray());
$tag_translation->name = 'Tag N°5';
$tag_translation
->save();
$this->tags[] = $tag;
}