You are here

protected function BambooTwigI18nTest::setUpArticles in Bamboo Twig 8.3

Setup default node for testing.

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

File

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

Class

BambooTwigI18nTest
Tests I18n twig filters and functions.

Namespace

Drupal\Tests\bamboo_twig\Functional

Code

protected function setUpArticles() {

  // Create an article content type that we will use for testing.
  $this
    ->drupalCreateContentType([
    'type' => 'article',
    'name' => 'Article',
  ]);

  // Add default nodes.
  $this->articles = [];
  $article = $this->entityTypeManager
    ->getStorage('node')
    ->create([
    'type' => 'article',
    'title' => 'News N°1',
  ]);
  $article
    ->save();
  $this->articles[] = $article;
  $article = $this->entityTypeManager
    ->getStorage('node')
    ->create([
    'type' => 'article',
    'title' => 'News N°2',
  ]);
  $article
    ->save();
  $article_translation = $article
    ->addTranslation('fr', $article
    ->toArray());
  $article_translation->title = 'Article N°2';
  $article_translation
    ->save();
  $this->articles[] = $article;
  $article = $this->entityTypeManager
    ->getStorage('node')
    ->create([
    'type' => 'article',
    'title' => 'News N°3',
  ]);
  $article
    ->save();
  $article_translation = $article
    ->addTranslation('fr', $article
    ->toArray());
  $article_translation->title = 'Article N°3';
  $article_translation
    ->save();
  $article_translation = $article
    ->addTranslation('de', $article
    ->toArray());
  $article_translation->title = 'Artikel N°3';
  $article_translation
    ->save();
  $this->articles[] = $article;
}