diff --git a/core/modules/config/config.api.php b/core/modules/config/config.api.php index d83684c..e5dba3d 100644 --- a/core/modules/config/config.api.php +++ b/core/modules/config/config.api.php @@ -72,11 +72,14 @@ function hook_config_import_change($name, $new_config, $old_config) { $id = substr($name, strlen($entity_info['config prefix']) + 1); $config_test = entity_load('config_test', $id); + // Store the original config, and iterate through each property to store it. $config_test->original = clone $config_test; foreach ($old_config->get() as $property => $value) { $config_test->original->$property = $value; } + // Iterate through each property of the new config, copying it to the + // configurable test object. foreach ($new_config->get() as $property => $value) { $config_test->$property = $value; } diff --git a/core/modules/config/lib/Drupal/config/ConfigStorageController.php b/core/modules/config/lib/Drupal/config/ConfigStorageController.php index 57c2583..12d62b4 100644 --- a/core/modules/config/lib/Drupal/config/ConfigStorageController.php +++ b/core/modules/config/lib/Drupal/config/ConfigStorageController.php @@ -137,7 +137,7 @@ public function loadByProperties(array $values = array()) { * Drupal\taxonomy\TermStorageController::buildQuery() for examples. * * @param $ids - * An array of entity IDs, or FALSE to load all entities. + * An array of entity IDs, or NULL to load all entities. * @param $revision_id * The ID of the revision to load, or FALSE if this query is asking for the * most current revision(s). @@ -149,6 +149,7 @@ protected function buildQuery($ids, $revision_id = FALSE) { $config_class = $this->entityInfo['entity class']; $prefix = $this->entityInfo['config prefix'] . '.'; + // Load all of the configurables. if ($ids === NULL) { $names = drupal_container()->get('config.storage')->listAll($prefix); $result = array(); @@ -161,6 +162,7 @@ protected function buildQuery($ids, $revision_id = FALSE) { else { $result = array(); foreach ($ids as $id) { + // Add the prefix to the ID to serve as the configurable name. $config = config($prefix . $id); if (!$config->isNew()) { $result[$id] = new $config_class($config->get(), $this->entityType); diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigConfigurableTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigConfigurableTest.php index 0867812..3e73528 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigConfigurableTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigConfigurableTest.php @@ -14,6 +14,11 @@ */ class ConfigConfigurableTest extends WebTestBase { + /** + * Modules to enable. + * + * @var array + */ public static $modules = array('config_test'); public static function getInfo() { @@ -28,52 +33,56 @@ public static function getInfo() { * Tests basic CRUD operations through the UI. */ function testCRUD() { + $id = strtolower($this->randomName()); + $label1 = $this->randomName(); + $label2 = $this->randomName(); + $label3 = $this->randomName(); + // Create a configurable entity. - $id = 'thingie'; $edit = array( 'id' => $id, - 'label' => 'Thingie', + 'label' => $label1, ); $this->drupalPost('admin/structure/config_test/add', $edit, 'Save'); $this->assertResponse(200); - $this->assertText('Thingie'); + $this->assertText($label1); // Update the configurable entity. $this->assertLinkByHref('admin/structure/config_test/manage/' . $id); $edit = array( - 'label' => 'Thongie', + 'label' => $label2, ); $this->drupalPost('admin/structure/config_test/manage/' . $id, $edit, 'Save'); $this->assertResponse(200); - $this->assertNoText('Thingie'); - $this->assertText('Thongie'); + $this->assertNoText($label1); + $this->assertText($label2); // Delete the configurable entity. $this->assertLinkByHref('admin/structure/config_test/manage/' . $id . '/delete'); $this->drupalPost('admin/structure/config_test/manage/' . $id . '/delete', array(), 'Delete'); $this->assertResponse(200); - $this->assertNoText('Thingie'); - $this->assertNoText('Thongie'); + $this->assertNoText($label1); + $this->assertNoText($label2); // Re-create a configurable entity. $edit = array( 'id' => $id, - 'label' => 'Thingie', + 'label' => $label1, ); $this->drupalPost('admin/structure/config_test/add', $edit, 'Save'); $this->assertResponse(200); - $this->assertText('Thingie'); + $this->assertText($label1); // Rename the configurable entity's ID/machine name. $this->assertLinkByHref('admin/structure/config_test/manage/' . $id); - $new_id = 'zingie'; $edit = array( - 'id' => $new_id, - 'label' => 'Zingie', + 'id' => strtolower($this->randomName()), + 'label' => $label3, ); $this->drupalPost('admin/structure/config_test/manage/' . $id, $edit, 'Save'); $this->assertResponse(200); - $this->assertNoText('Thingie'); - $this->assertText('Zingie'); + $this->assertNoText($label1); + $this->assertText($label3); } + } diff --git a/core/modules/config/tests/config_test/config_test.module b/core/modules/config/tests/config_test/config_test.module index e5550d0..5d422ad 100644 --- a/core/modules/config/tests/config_test/config_test.module +++ b/core/modules/config/tests/config_test/config_test.module @@ -1,5 +1,10 @@ original = clone $config_test; foreach ($old_config->get() as $property => $value) { $config_test->original->$property = $value; } + // Iterate through each property of the new config, copying it to the + // configurable test object. foreach ($new_config->get() as $property => $value) { $config_test->$property = $value; } diff --git a/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTest.php b/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTest.php index 7431e4b..ca3550c 100644 --- a/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTest.php +++ b/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTest.php @@ -14,10 +14,25 @@ */ class ConfigTest extends ConfigurableBase { + /** + * The machine name for the configurable. + * + * @var string + */ public $id; + /** + * The UUID for the configurable. + * + * @var string + */ public $uuid; + /** + * The human-readable name of the configurable. + * + * @var string + */ public $label; /**