function LayoutBuilderTest::testPreserverEntityValues
Same name in other branches
- 8.9.x core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderTest::testPreserverEntityValues()
- 10 core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderTest::testPreserverEntityValues()
- 11.x core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderTest::testPreserverEntityValues()
Tests that the Layout Builder preserves entity values.
File
-
core/
modules/ layout_builder/ tests/ src/ Functional/ LayoutBuilderTest.php, line 234
Class
- LayoutBuilderTest
- Tests the Layout Builder UI.
Namespace
Drupal\Tests\layout_builder\FunctionalCode
public function testPreserverEntityValues() {
$assert_session = $this->assertSession();
$page = $this->getSession()
->getPage();
$this->drupalLogin($this->drupalCreateUser([
'configure any layout',
'administer node display',
]));
// From the manage display page, go to manage the layout.
$this->drupalGet('admin/structure/types/manage/bundle_with_section_field/display/default');
$this->submitForm([
'layout[enabled]' => TRUE,
], 'Save');
$this->submitForm([
'layout[allow_custom]' => TRUE,
], 'Save');
// @todo This should not be necessary.
$this->container
->get('entity_field.manager')
->clearCachedFieldDefinitions();
$this->drupalGet('node/1');
$assert_session->pageTextContains('The first node body');
// Create a layout override which will store the current node in the
// tempstore.
$page->clickLink('Layout');
$page->clickLink('Add block');
$page->clickLink('Powered by Drupal');
$page->pressButton('Add block');
// Update the node to make a change that is not in the tempstore version.
$node = Node::load(1);
$node->set('body', 'updated body');
$node->save();
$page->clickLink('View');
$assert_session->pageTextNotContains('The first node body');
$assert_session->pageTextContains('updated body');
$page->clickLink('Layout');
$page->pressButton('Save layout');
// Ensure that saving the layout does not revert other field values.
$assert_session->addressEquals('node/1');
$assert_session->pageTextNotContains('The first node body');
$assert_session->pageTextContains('updated body');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.