Commit 1867d618 authored by alexpott's avatar alexpott

Issue #2220559 by benjy, swentel, lokeoke, visabhishek, hampercm,...

Issue #2220559 by benjy, swentel, lokeoke, visabhishek, hampercm, joshi.rohit100, amitgoyal: Entity displays must have a settings array
parent 86f62c10
......@@ -288,6 +288,9 @@ public function setComponent($name, array $options = array()) {
$options = $this->pluginManager->prepareConfiguration($field_definition->getType(), $options);
}
// Ensure we always have an empty settings and array.
$options += ['settings' => [], 'third_party_settings' => []];
$this->content[$name] = $options;
unset($this->hidden[$name]);
unset($this->plugins[$name]);
......
......@@ -40,15 +40,15 @@ public function testEntityDisplayCRUD() {
// Check that providing no 'weight' results in the highest current weight
// being assigned. The 'name' field's formatter has weight -5, therefore
// these follow.
$expected['component_1'] = array('weight' => -4);
$expected['component_2'] = array('weight' => -3);
$expected['component_1'] = array('weight' => -4, 'settings' => array(), 'third_party_settings' => array());
$expected['component_2'] = array('weight' => -3, 'settings' => array(), 'third_party_settings' => array());
$display->setComponent('component_1');
$display->setComponent('component_2');
$this->assertEqual($display->getComponent('component_1'), $expected['component_1']);
$this->assertEqual($display->getComponent('component_2'), $expected['component_2']);
// Check that arbitrary options are correctly stored.
$expected['component_3'] = array('weight' => 10, 'third_party_settings' => array('field_test' => array('foo' => 'bar')));
$expected['component_3'] = array('weight' => 10, 'third_party_settings' => array('field_test' => array('foo' => 'bar')), 'settings' => array());
$display->setComponent('component_3', $expected['component_3']);
$this->assertEqual($display->getComponent('component_3'), $expected['component_3']);
......@@ -109,14 +109,14 @@ public function testEntityGetDisplay() {
$this->assertTrue($display->isNew());
// Add some components and save the display.
$display->setComponent('component_1', array('weight' => 10))
$display->setComponent('component_1', array('weight' => 10, 'settings' => array()))
->save();
// Check that entity_get_display() returns the correct object.
$display = entity_get_display('entity_test', 'entity_test', 'default');
$this->assertFalse($display->isNew());
$this->assertEqual($display->id, 'entity_test.entity_test.default');
$this->assertEqual($display->getComponent('component_1'), array('weight' => 10));
$this->assertEqual($display->getComponent('component_1'), array( 'weight' => 10, 'settings' => array(), 'third_party_settings' => array()));
}
/**
......@@ -139,7 +139,7 @@ public function testExtraFieldComponent() {
$display->removeComponent('display_extra_field');
$display->setComponent('display_extra_field_hidden', array('weight' => 10));
$this->assertNull($display->getComponent('display_extra_field'));
$this->assertEqual($display->getComponent('display_extra_field_hidden'), array('weight' => 10));
$this->assertEqual($display->getComponent('display_extra_field_hidden'), array('weight' => 10, 'settings' => array(), 'third_party_settings' => array()));
}
/**
......
......@@ -40,7 +40,7 @@ public function testEntityGetFromDisplay() {
$form_display = entity_get_form_display('entity_test', 'entity_test', 'default');
$this->assertFalse($form_display->isNew());
$this->assertEqual($form_display->id, 'entity_test.entity_test.default');
$this->assertEqual($form_display->getComponent('component_1'), array('weight' => 10));
$this->assertEqual($form_display->getComponent('component_1'), array('weight' => 10, 'settings' => array(), 'third_party_settings' => array()));
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment