You are here

protected function LayoutBuilderTranslationTest::addEntityTranslation in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/layout_builder/tests/src/Functional/LayoutBuilderTranslationTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderTranslationTest::addEntityTranslation()
  2. 9 core/modules/layout_builder/tests/src/Functional/LayoutBuilderTranslationTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderTranslationTest::addEntityTranslation()

Adds an entity translation.

File

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

Class

LayoutBuilderTranslationTest
Tests that the Layout Builder works with translated content.

Namespace

Drupal\Tests\layout_builder\Functional

Code

protected function addEntityTranslation() {
  $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);
}