Skip to content
Snippets Groups Projects
Commit b3786231 authored by Jess's avatar Jess
Browse files

Issue #3033686 by tedbow, tim.plunkett, xjm, amateescu: Saving Layout override...

Issue #3033686 by tedbow, tim.plunkett, xjm, amateescu: Saving Layout override will revert other field values to their values when the Layout was started
parent 0b724181
No related branches found
No related tags found
No related merge requests found
......@@ -110,18 +110,6 @@ public function buildForm(array $form, FormStateInterface $form_state, SectionSt
return $form;
}
/**
* {@inheritdoc}
*/
public function buildEntity(array $form, FormStateInterface $form_state) {
// \Drupal\Core\Entity\EntityForm::buildEntity() clones the entity object.
// Keep it in sync with the one used by the section storage.
$this->setEntity($this->sectionStorage->getContextValue('entity'));
$entity = parent::buildEntity($form, $form_state);
$this->sectionStorage->setContextValue('entity', $entity);
return $entity;
}
/**
* {@inheritdoc}
*/
......
......@@ -106,6 +106,53 @@ public function testOverrides() {
$assert_session->pageTextNotContains('This is an override');
}
/**
* Tests that the Layout Builder preserves entity values.
*/
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->drupalPostForm(NULL, ['layout[enabled]' => TRUE], 'Save');
$this->drupalPostForm(NULL, ['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');
}
/**
* {@inheritdoc}
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment