public function LayoutBuilderNestedFormUiTest::testAddingFormBlocksToDefaults in Drupal 8
Same name and namespace in other branches
- 9 core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderNestedFormUiTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderNestedFormUiTest::testAddingFormBlocksToDefaults()
- 10 core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderNestedFormUiTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderNestedFormUiTest::testAddingFormBlocksToDefaults()
Test blocks containing forms can be successfully saved editing defaults.
File
- core/
modules/ layout_builder/ tests/ src/ FunctionalJavascript/ LayoutBuilderNestedFormUiTest.php, line 67
Class
- LayoutBuilderNestedFormUiTest
- Tests placing blocks containing forms in theLayout Builder UI.
Namespace
Drupal\Tests\layout_builder\FunctionalJavascriptCode
public function testAddingFormBlocksToDefaults() {
$this
->drupalLogin($this
->drupalCreateUser([
'configure any layout',
'administer node display',
]));
// From the manage display page, enable Layout Builder.
$field_ui_prefix = 'admin/structure/types/manage/bundle_with_section_field';
$this
->drupalGet("{$field_ui_prefix}/display/default");
$this
->drupalPostForm(NULL, [
'layout[enabled]' => TRUE,
], 'Save');
$this
->drupalPostForm(NULL, [
'layout[allow_custom]' => TRUE,
], 'Save');
// Save the entity view display so that it can be reverted to later.
/** @var \Drupal\Core\Config\StorageInterface $active_config_storage */
$active_config_storage = $this->container
->get('config.storage');
$original_display_config_data = $active_config_storage
->read('core.entity_view_display.node.bundle_with_section_field.default');
/** @var \Drupal\Core\Config\Entity\ConfigEntityStorageInterface $entity_view_display_storage */
$entity_view_display_storage = $this->container
->get('entity_type.manager')
->getStorage('entity_view_display');
$entity_view_display = $entity_view_display_storage
->load('node.bundle_with_section_field.default');
$expected_save_message = 'The layout has been saved.';
foreach (static::FORM_BLOCK_LABELS as $label) {
$this
->addFormBlock($label, "{$field_ui_prefix}/display/default", $expected_save_message);
// Revert the entity view display back to remove the previously added form
// block.
$entity_view_display = $entity_view_display_storage
->updateFromStorageRecord($entity_view_display, $original_display_config_data);
$entity_view_display
->save();
}
}