You are here

protected function TermTranslationFieldViewTest::setUpNode in Drupal 8

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

Creates a test subject node, with translation.

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

File

core/modules/taxonomy/tests/src/Functional/TermTranslationFieldViewTest.php, line 77

Class

TermTranslationFieldViewTest
Tests the translation of taxonomy terms field on nodes.

Namespace

Drupal\Tests\taxonomy\Functional

Code

protected function setUpNode() {

  /** @var \Drupal\node\Entity\Node $node */
  $node = Node::create([
    'title' => $this
      ->randomMachineName(),
    'type' => 'article',
    'description' => [
      [
        'value' => $this
          ->randomMachineName(),
        'format' => 'basic_html',
      ],
    ],
    $this->termFieldName => [
      [
        'target_id' => $this->term
          ->id(),
      ],
    ],
    'langcode' => $this->baseLangcode,
  ]);
  $node
    ->save();
  $node
    ->addTranslation($this->translateToLangcode, $node
    ->toArray());
  $node
    ->save();
  $this->node = $node;
}