function TranslatableFieldTest::testSectionsClearedOnCreateTranslation
Tests that sections on cleared when creating a new translation.
File
-
core/
modules/ layout_builder/ tests/ src/ Kernel/ TranslatableFieldTest.php, line 67
Class
- TranslatableFieldTest
- Tests Layout Builder with a translatable layout field.
Namespace
Drupal\Tests\layout_builder\KernelCode
public function testSectionsClearedOnCreateTranslation() {
$section_data = [
new Section('layout_onecol', [], [
'first-uuid' => new SectionComponent('first-uuid', '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.