diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php index aa1cb34..c99db71 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php @@ -25,7 +25,7 @@ * * @var string */ - protected $originalID; + protected $originalId; /** * The enabled/disabled status of the configuration entity. @@ -44,22 +44,24 @@ public function __construct(array $values, $entity_type) { // Configuration entity IDs are strings, and '0' is a valid ID. $original_id = $this->id(); if ($original_id !== NULL && $original_id !== '') { - $this->setOriginalID($original_id); + $this->setOriginalId($original_id); } } /** - * Implements ConfigEntityInterface::getOriginalID(). + * {@inheritdoc} */ - public function getOriginalID() { - return $this->originalID; + public function getOriginalId() { + return $this->originalId; } /** - * Implements ConfigEntityInterface::setOriginalID(). + * {@inheritdoc} */ - public function setOriginalID($id) { - $this->originalID = $id; + public function setOriginalId($id) { + $this->originalId = $id; + + return $this; } /** @@ -130,7 +132,7 @@ public function status() { public function createDuplicate() { $duplicate = parent::createDuplicate(); // Prevent the new duplicate from being misinterpreted as a rename. - $duplicate->setOriginalID(NULL); + $duplicate->setOriginalId(NULL); return $duplicate; } diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php index 0d9bd71..2475a88 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php @@ -20,7 +20,7 @@ * @return string|null * The original ID, if any. */ - public function getOriginalID(); + public function getOriginalId(); /** * Sets the original ID. @@ -28,9 +28,9 @@ public function getOriginalID(); * @param string $id * The new ID to set as original ID. * - * @return void + * @return \Drupal\Core\Config\Entity\ConfigEntityInterface */ - public function setOriginalID($id); + public function setOriginalId($id); /** * Enables the configuration entity. diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityUnitTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityUnitTest.php index 2481208..db48d96 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityUnitTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityUnitTest.php @@ -7,6 +7,7 @@ namespace Drupal\config\Tests; +use Drupal\Core\Entity\EntityInterface; use Drupal\simpletest\DrupalUnitTestBase; /** @@ -21,6 +22,13 @@ class ConfigEntityUnitTest extends DrupalUnitTestBase { */ public static $modules = array('config_test'); + /** + * The config_test entity storage controller. + * + * @var \Drupal\config_test\ConfigTestStorageController + */ + protected $storage; + public static function getInfo() { return array( 'name' => 'Configuration entity methods', @@ -30,31 +38,39 @@ public static function getInfo() { } /** + * {@inheritdoc} + */ + protected function setUp() { + parent::setUp(); + $this->storage = $this->container->get('entity.manager')->getStorageController('config_test'); + } + + /** * Tests storage controller methods. */ public function testStorageControllerMethods() { - $controller = $this->container->get('entity.manager')->getStorageController('config_test'); $info = entity_get_info('config_test'); $expected = $info['config_prefix'] . '.'; - $this->assertIdentical($controller->getConfigPrefix(), $expected); + $this->assertIdentical($this->storage->getConfigPrefix(), $expected); // Test the static extractID() method. $expected_id = 'test_id'; $config_name = $info['config_prefix'] . '.' . $expected_id; - $this->assertIdentical($controller::getIDFromConfigName($config_name, $info['config_prefix']), $expected_id); + $storage = $this->storage; + $this->assertIdentical($storage::getIDFromConfigName($config_name, $info['config_prefix']), $expected_id); // Create three entities, two with the same style. $style = $this->randomName(8); for ($i = 0; $i < 2; $i++) { - $entity = $controller->create(array( + $entity = $this->storage->create(array( 'id' => $this->randomName(), 'label' => $this->randomString(), 'style' => $style, )); $entity->save(); } - $entity = $controller->create(array( + $entity = $this->storage->create(array( 'id' => $this->randomName(), 'label' => $this->randomString(), // Use a different length for the entity to ensure uniqueness. @@ -62,12 +78,22 @@ public function testStorageControllerMethods() { )); $entity->save(); - $entities = $controller->loadByProperties(); + $entities = $this->storage->loadByProperties(); $this->assertEqual(count($entities), 3, 'Three entities are loaded when no properties are specified.'); - $entities = $controller->loadByProperties(array('style' => $style)); + $entities = $this->storage->loadByProperties(array('style' => $style)); $this->assertEqual(count($entities), 2, 'Two entities are loaded when the style property is specified.'); $this->assertEqual(reset($entities)->get('style'), $style, 'The loaded entities have the style value specified.'); } + /** + * Tests getOriginalId() and setOriginalId(). + */ + protected function testGetOriginalId() { + $entity = $this->storage->create(array()); + $id = $this->randomName(); + $this->assertTrue($entity->setOriginalId($id) instanceof EntityInterface); + $this->assertIdentical($entity->getOriginalId(), $id); + } + } diff --git a/core/modules/views_ui/lib/Drupal/views_ui/ViewUI.php b/core/modules/views_ui/lib/Drupal/views_ui/ViewUI.php index aa78fb9..0ec9f87 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/ViewUI.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewUI.php @@ -1011,17 +1011,17 @@ public function status() { } /** - * Implements \Drupal\Core\Config\Entity\ConfigEntityInterface::getOriginalID(). + * {@inheritdoc} */ - public function getOriginalID() { - return $this->storage->getOriginalID(); + public function getOriginalId() { + return $this->storage->getOriginalId(); } /** - * Implements \Drupal\Core\Config\Entity\ConfigEntityInterface::setOriginalID(). + * {@inheritdoc} */ - public function setOriginalID($id) { - return $this->storage->setOriginalID($id); + public function setOriginalId($id) { + return $this->storage->setOriginalId($id); } /**