function LayoutBuilderDefaultValuesTest::setUp
Same name in other branches
- 9 core/modules/layout_builder/tests/src/Functional/LayoutBuilderDefaultValuesTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderDefaultValuesTest::setUp()
- 10 core/modules/layout_builder/tests/src/Functional/LayoutBuilderDefaultValuesTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderDefaultValuesTest::setUp()
Overrides BrowserTestBase::setUp
File
-
core/
modules/ layout_builder/ tests/ src/ Functional/ LayoutBuilderDefaultValuesTest.php, line 50
Class
- LayoutBuilderDefaultValuesTest
- Tests rendering default field values in Layout Builder.
Namespace
Drupal\Tests\layout_builder\FunctionalCode
protected function setUp() : void {
parent::setUp();
$this->createContentType([
'type' => 'test_node_type',
'name' => 'Test Node Type',
]);
$this->addTextFields();
$this->addImageFields();
// Create node 1 with specific values.
$this->createNode([
'type' => 'test_node_type',
'title' => 'Test Node 1 Has Values',
'field_string_no_default' => 'No default, no problem.',
'field_string_with_default' => 'It is ok to be different',
'field_string_with_callback' => 'Not from a callback',
'field_string_late_default' => 'I am way ahead of you.',
'field_image_storage_default' => [
'target_id' => 3,
'alt' => 'My third alt text',
],
'field_image_instance_default' => [
'target_id' => 4,
'alt' => 'My fourth alt text',
],
'field_image_both_defaults' => [
'target_id' => 5,
'alt' => 'My fifth alt text',
],
'field_image_no_default' => [
'target_id' => 6,
'alt' => 'My sixth alt text',
],
]);
// Create node 2 relying on defaults.
$this->createNode([
'type' => 'test_node_type',
'title' => 'Test Node 2 Uses Defaults',
]);
// Add default value to field_string_late_default.
$field = FieldConfig::loadByName('node', 'test_node_type', 'field_string_late_default');
$field->setDefaultValue('Too late!');
$field->save();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.