Issue #1668820 follow-up by tim.plunkett, sun: Documentation fixes and clean-ups to Configurables patch.
parent
cc204b607f
commit
fe247ca5fc
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -137,7 +137,7 @@ class ConfigStorageController implements StorageControllerInterface {
|
|||
* 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 @@ class ConfigStorageController implements StorageControllerInterface {
|
|||
$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 @@ class ConfigStorageController implements StorageControllerInterface {
|
|||
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);
|
||||
|
|
|
@ -14,6 +14,11 @@ use Drupal\simpletest\WebTestBase;
|
|||
*/
|
||||
class ConfigConfigurableTest extends WebTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('config_test');
|
||||
|
||||
public static function getInfo() {
|
||||
|
@ -28,52 +33,56 @@ class ConfigConfigurableTest extends WebTestBase {
|
|||
* 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Provides Config module hook implementations for testing purposes.
|
||||
*/
|
||||
|
||||
use Drupal\config_test\ConfigTest;
|
||||
|
||||
require_once dirname(__FILE__) . '/config_test.hooks.inc';
|
||||
|
@ -35,11 +40,14 @@ function config_test_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;
|
||||
}
|
||||
|
|
|
@ -14,10 +14,25 @@ use Drupal\config\ConfigurableBase;
|
|||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue