function TermTranslationTest::testTermsTranslation

Same name in other branches
  1. 8.9.x core/modules/taxonomy/tests/src/Functional/TermTranslationTest.php \Drupal\Tests\taxonomy\Functional\TermTranslationTest::testTermsTranslation()
  2. 10 core/modules/taxonomy/tests/src/Functional/TermTranslationTest.php \Drupal\Tests\taxonomy\Functional\TermTranslationTest::testTermsTranslation()
  3. 11.x 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');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.