protected function LayoutBuilderTranslationTest::setUpEntities in Layout Builder Symmetric Translations 8
Setup translated entity with layouts.
1 call to LayoutBuilderTranslationTest::setUpEntities()
- LayoutBuilderTranslationTest::setUp in tests/
src/ Functional/ LayoutBuilderTranslationTest.php
File
- tests/
src/ Functional/ LayoutBuilderTranslationTest.php, line 267
Class
- LayoutBuilderTranslationTest
- Tests that the Layout Builder UI works with translated content.
Namespace
Drupal\Tests\layout_builder_st\FunctionalCode
protected function setUpEntities() {
$this
->drupalLogin($this->administrator);
$field_ui_prefix = 'entity_test_mul/structure/entity_test_mul';
// Allow overrides for the layout.
$this
->drupalPostForm("{$field_ui_prefix}/display/default", [
'layout[enabled]' => TRUE,
], 'Save');
$this
->drupalPostForm("{$field_ui_prefix}/display/default", [
'layout[allow_custom]' => TRUE,
], 'Save');
// @todo The Layout Builder UI relies on local tasks; fix in
// https://www.drupal.org/project/drupal/issues/2917777.
$this
->drupalPlaceBlock('local_tasks_block');
// Create a test entity.
$id = $this
->createEntity([
$this->fieldName => [
[
'value' => 'The untranslated field value',
],
],
], $this->langcodes[0]);
$storage = $this->container
->get('entity_type.manager')
->getStorage($this->entityTypeId);
$storage
->resetCache([
$id,
]);
$this->entity = $storage
->load($id);
// Create a translation.
$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
->drupalPostForm($add_translation_url, [
"{$this->fieldName}[0][value]" => 'The translated field value',
], 'Save');
}