function LayoutBuilderFormModeTest::setUp
Same name in other branches
- 9 core/modules/layout_builder/tests/src/Functional/LayoutBuilderFormModeTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderFormModeTest::setUp()
- 10 core/modules/layout_builder/tests/src/Functional/LayoutBuilderFormModeTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderFormModeTest::setUp()
Overrides BrowserTestBase::setUp
File
-
core/
modules/ layout_builder/ tests/ src/ Functional/ LayoutBuilderFormModeTest.php, line 39
Class
- LayoutBuilderFormModeTest
- Tests Layout Builder forms.
Namespace
Drupal\Tests\layout_builder\FunctionalCode
protected function setUp() : void {
parent::setUp();
// Set up a field with a validation constraint.
$field_storage = FieldStorageConfig::create([
'field_name' => 'foo',
'entity_type' => 'entity_test',
'type' => 'string',
]);
$field_storage->save();
FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'entity_test',
// Expecting required value.
'required' => TRUE,
])->save();
// Enable layout builder custom layouts.
LayoutBuilderEntityViewDisplay::create([
'targetEntityType' => 'entity_test',
'bundle' => 'entity_test',
'mode' => 'default',
'status' => TRUE,
])->enable()
->enableLayoutBuilder()
->setOverridable()
->save();
// Add the form mode and show the field with a constraint.
EntityFormMode::create([
'id' => 'entity_test.layout_builder',
'label' => 'Layout Builder',
'targetEntityType' => 'entity_test',
])->save();
EntityFormDisplay::create([
'targetEntityType' => 'entity_test',
'bundle' => 'entity_test',
'mode' => 'layout_builder',
'status' => TRUE,
])->setComponent('foo', [
'type' => 'string_textfield',
])
->save();
$this->drupalLogin($this->drupalCreateUser([
'view test entity',
'configure any layout',
'configure all entity_test entity_test layout overrides',
]));
EntityTest::create()->setName($this->randomMachineName())
->save();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.