diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php index b2a94b0..3dd0b0a 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php @@ -470,11 +470,11 @@ public function importChange($name, Config $new_config, Config $old_config) { $entity->original = clone $entity; foreach ($old_config->get() as $property => $value) { - $entity->original->$property = $value; + $entity->original->set($property, $value); } foreach ($new_config->get() as $property => $value) { - $entity->$property = $value; + $entity->set($property, $value); } $entity->save(); diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php index f19c03d..1eacd3b 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php @@ -43,10 +43,10 @@ function testList() { // Get a list of ConfigTest entities and confirm that it contains the // ConfigTest entity provided by the config_test module. - // @see config_test.dynamic.default.yml + // @see config_test.dynamic.test.config.yml $list = $controller->load(); $this->assertEqual(count($list), 1, '1 ConfigTest entity found.'); - $entity = $list['default']; + $entity = $list['test.config']; $this->assertTrue(!empty($entity), '"Default" ConfigTest entity ID found.'); $this->assertTrue($entity instanceof ConfigTest, '"Default" ConfigTest entity is an instance of ConfigTest.'); @@ -55,13 +55,13 @@ function testList() { $expected_operations = array( 'edit' => array ( 'title' => 'Edit', - 'href' => 'admin/structure/config_test/manage/default/edit', + 'href' => 'admin/structure/config_test/manage/test.config/edit', 'options' => $uri['options'], 'weight' => 10, ), 'delete' => array ( 'title' => 'Delete', - 'href' => 'admin/structure/config_test/manage/default/delete', + 'href' => 'admin/structure/config_test/manage/test.config/delete', 'options' => $uri['options'], 'weight' => 100, ), @@ -82,7 +82,7 @@ function testList() { $build_operations = $controller->buildOperations($entity); $expected_items = array( 'label' => 'Default', - 'id' => 'default', + 'id' => 'test.config', 'operations' => array( 'data' => $build_operations, ), @@ -126,7 +126,7 @@ function testListUI() { // the second contains the machine name, and the third contains the // operations list. $this->assertIdentical((string) $elements[0], 'Default'); - $this->assertIdentical((string) $elements[1], 'default'); + $this->assertIdentical((string) $elements[1], 'test.config'); $this->assertTrue($elements[2]->children()->xpath('//ul'), 'Operations list found.'); // Add a new entity using the operations link. @@ -177,7 +177,7 @@ function testListUI() { // Verify that the text of the label and machine name does not appear in // the list (though it may appear elsewhere on the page). $this->assertNoFieldByXpath('//td', 'Default', "No label found for deleted 'Default' entity."); - $this->assertNoFieldByXpath('//td', 'default', "No machine name found for deleted 'Default' entity."); + $this->assertNoFieldByXpath('//td', 'test.config', "No machine name found for deleted 'Default' entity."); // Confirm that the empty text is displayed. $this->assertText('There is no Test configuration yet.'); diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigImportTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigImportTest.php index 95089f7..d06acc8 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigImportTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigImportTest.php @@ -43,11 +43,11 @@ function setUp() { * Tests omission of module APIs for bare configuration operations. */ function testNoImport() { - $dynamic_name = 'config_test.dynamic.default'; + $dynamic_name = 'config_test.dynamic.test.config'; // Verify the default configuration values exist. $config = config($dynamic_name); - $this->assertIdentical($config->get('id'), 'default'); + $this->assertIdentical($config->get('id'), 'test.config'); // Verify that a bare config() does not involve module APIs. $this->assertFalse(isset($GLOBALS['hook_config_test'])); @@ -57,13 +57,13 @@ function testNoImport() { * Tests deletion of configuration during import. */ function testDeleted() { - $dynamic_name = 'config_test.dynamic.default'; + $dynamic_name = 'config_test.dynamic.test.config'; $storage = $this->container->get('config.storage'); $staging = $this->container->get('config.storage.staging'); // Verify the default configuration values exist. $config = config($dynamic_name); - $this->assertIdentical($config->get('id'), 'default'); + $this->assertIdentical($config->get('id'), 'test.config'); // Create an empty manifest to delete the configuration object. $staging->write('manifest.config_test.dynamic', array()); @@ -108,6 +108,7 @@ function testNew() { 'label' => 'New', 'style' => '', 'langcode' => 'und', + 'description' => '', ); $staging->write($dynamic_name, $original_dynamic_data); @@ -142,7 +143,7 @@ function testNew() { */ function testUpdated() { $name = 'config_test.system'; - $dynamic_name = 'config_test.dynamic.default'; + $dynamic_name = 'config_test.dynamic.test.config'; $storage = $this->container->get('config.storage'); $staging = $this->container->get('config.storage.staging'); diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php index dd24224..40d498e 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php @@ -60,6 +60,7 @@ function testImport() { 'label' => 'New', 'style' => '', 'langcode' => 'und', + 'description' => '', ); $staging->write($dynamic_name, $original_dynamic_data); @@ -128,4 +129,22 @@ function prepareSiteNameUpdate($new_site_name) { $config_data['name'] = $new_site_name; $staging->write('system.site', $config_data); } + + /** + * Tests updating existing configuration. + */ + public function testUpdate() { + // Create a staged version of the configuration object with different data. + $config_data = config('config_test.dynamic.test.config')->get(); + $config_data['description'] = $this->randomName(); + $this->container->get('config.storage.staging')->write('config_test.dynamic.test.config', $config_data); + + $this->drupalGet('admin/config/development/sync'); + $this->drupalPost(NULL, array(), t('Import all')); + $this->assertText(t('There is no configuration to import.')); + + $entity = entity_load('config_test', 'test.config'); + $this->assertIdentical($entity->get('description'), $config_data['description']); + } + } diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigInstallTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigInstallTest.php index b549119..ff57878 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigInstallTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigInstallTest.php @@ -34,7 +34,7 @@ function setUp() { */ function testModuleInstallation() { $default_config = 'config_test.system'; - $default_configuration_entity = 'config_test.dynamic.default'; + $default_configuration_entity = 'config_test.dynamic.test.config'; // Verify that default module config does not exist before installation yet. $config = config($default_config); diff --git a/core/modules/config/tests/config_test/config/config_test.dynamic.default.yml b/core/modules/config/tests/config_test/config/config_test.dynamic.default.yml deleted file mode 100644 index 3e50e3b..0000000 --- a/core/modules/config/tests/config_test/config/config_test.dynamic.default.yml +++ /dev/null @@ -1,2 +0,0 @@ -id: default -label: Default diff --git a/core/modules/config/tests/config_test/config/config_test.dynamic.test.config.yml b/core/modules/config/tests/config_test/config/config_test.dynamic.test.config.yml new file mode 100644 index 0000000..6917b1f --- /dev/null +++ b/core/modules/config/tests/config_test/config/config_test.dynamic.test.config.yml @@ -0,0 +1,3 @@ +id: test.config +label: Default +description: Default diff --git a/core/modules/config/tests/config_test/lib/Drupal/config_test/Plugin/Core/Entity/ConfigTest.php b/core/modules/config/tests/config_test/lib/Drupal/config_test/Plugin/Core/Entity/ConfigTest.php index 52da777..c99ecc2 100644 --- a/core/modules/config/tests/config_test/lib/Drupal/config_test/Plugin/Core/Entity/ConfigTest.php +++ b/core/modules/config/tests/config_test/lib/Drupal/config_test/Plugin/Core/Entity/ConfigTest.php @@ -62,4 +62,25 @@ class ConfigTest extends ConfigEntityBase { */ public $style; + /** + * The description for the configuration entity. + * + * @var string + */ + protected $description; + + /** + * Overrides \Drupal\Core\Config\Entity\ConfigEntityBase::getExportProperties(); + */ + public function getExportProperties() { + $properties = parent::getExportProperties(); + $protected_names = array( + 'description', + ); + foreach ($protected_names as $name) { + $properties[$name] = $this->get($name); + } + return $properties; + } + }