You are here

public function TermTranslationTest::testTermsTranslation in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/taxonomy/tests/src/Functional/TermTranslationTest.php \Drupal\Tests\taxonomy\Functional\TermTranslationTest::testTermsTranslation()

Tests translation of terms are showed in the node.

File

core/modules/taxonomy/tests/src/Functional/TermTranslationTest.php, line 95

Class

TermTranslationTest
Tests for proper breadcrumb translation.

Namespace

Drupal\Tests\taxonomy\Functional

Code

public function testTermsTranslation() {

  // Set the display of the term reference field on the article content type
  // to "Check boxes/radio buttons".
  \Drupal::service('entity_display.repository')
    ->getFormDisplay('node', 'article')
    ->setComponent($this->termFieldName, [
    'type' => 'options_buttons',
  ])
    ->save();
  $this
    ->drupalLogin($this
    ->drupalCreateUser([
    'create article content',
  ]));

  // Test terms are listed.
  $this
    ->drupalget('node/add/article');
  $this
    ->assertSession()
    ->pageTextContains('one');
  $this
    ->assertSession()
    ->pageTextContains('two');
  $this
    ->assertSession()
    ->pageTextContains('three');

  // Test terms translated are listed.
  $this
    ->drupalget('hu/node/add/article');
  $this
    ->assertSession()
    ->pageTextContains('translatedOne');
  $this
    ->assertSession()
    ->pageTextContains('translatedTwo');
  $this
    ->assertSession()
    ->pageTextContains('translatedThree');
}