function LayoutBuilderTranslationTest::addEntityTranslation

Same name in other branches
  1. 9 core/modules/layout_builder/tests/src/Functional/LayoutBuilderTranslationTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderTranslationTest::addEntityTranslation()
  2. 8.9.x core/modules/layout_builder/tests/src/Functional/LayoutBuilderTranslationTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderTranslationTest::addEntityTranslation()
  3. 10 core/modules/layout_builder/tests/src/Functional/LayoutBuilderTranslationTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderTranslationTest::addEntityTranslation()

Adds an entity translation.

2 calls to LayoutBuilderTranslationTest::addEntityTranslation()
LayoutBuilderTranslationTest::testLayoutOverrideBeforeTranslation in core/modules/layout_builder/tests/src/Functional/LayoutBuilderTranslationTest.php
Tests that layout overrides work when created before a translation.
LayoutBuilderTranslationTest::testTranslationBeforeLayoutOverride in core/modules/layout_builder/tests/src/Functional/LayoutBuilderTranslationTest.php
Tests that layout overrides work when created after a translation.

File

core/modules/layout_builder/tests/src/Functional/LayoutBuilderTranslationTest.php, line 179

Class

LayoutBuilderTranslationTest
Tests that the Layout Builder works with translated content.

Namespace

Drupal\Tests\layout_builder\Functional

Code

protected function addEntityTranslation() : void {
    $user = $this->loggedInUser;
    $this->drupalLogin($this->translator);
    $add_translation_url = Url::fromRoute("entity.{$this->entityTypeId}.content_translation_add", [
        $this->entityTypeId => $this->entity
            ->id(),
        'source' => $this->langcodes[0],
        'target' => $this->langcodes[2],
    ]);
    $this->drupalGet($add_translation_url);
    $this->submitForm([
        "{$this->fieldName}[0][value]" => 'The translated field value',
    ], 'Save');
    $this->drupalLogin($user);
}

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