function TranslatableFieldTest::testSectionsClearedOnCreateTranslation
Same name in other branches
- 9 core/modules/layout_builder/tests/src/Kernel/TranslatableFieldTest.php \Drupal\Tests\layout_builder\Kernel\TranslatableFieldTest::testSectionsClearedOnCreateTranslation()
- 8.9.x core/modules/layout_builder/tests/src/Kernel/TranslatableFieldTest.php \Drupal\Tests\layout_builder\Kernel\TranslatableFieldTest::testSectionsClearedOnCreateTranslation()
- 10 core/modules/layout_builder/tests/src/Kernel/TranslatableFieldTest.php \Drupal\Tests\layout_builder\Kernel\TranslatableFieldTest::testSectionsClearedOnCreateTranslation()
Tests that sections on cleared when creating a new translation.
File
-
core/
modules/ layout_builder/ tests/ src/ Kernel/ TranslatableFieldTest.php, line 69
Class
- TranslatableFieldTest
- Tests Layout Builder with a translatable layout field.
Namespace
Drupal\Tests\layout_builder\KernelCode
public function testSectionsClearedOnCreateTranslation() : void {
$section_data = [
new Section('layout_onecol', [], [
'10000000-0000-1000-a000-000000000000' => new SectionComponent('10000000-0000-1000-a000-000000000000', 'content', [
'id' => 'foo',
]),
]),
];
$entity = EntityTest::create([
OverridesSectionStorage::FIELD_NAME => $section_data,
]);
$entity->save();
$this->assertFalse($entity->get(OverridesSectionStorage::FIELD_NAME)
->isEmpty());
$entity = EntityTest::load($entity->id());
/** @var \Drupal\entity_test\Entity\EntityTest $translation */
$translation = $entity->addTranslation('es', $entity->toArray());
// Per-language layouts are not supported.
$this->assertTrue($translation->get(OverridesSectionStorage::FIELD_NAME)
->isEmpty());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.