diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityUnitTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityUnitTest.php index 905ac98..14373a2 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityUnitTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityUnitTest.php @@ -43,25 +43,27 @@ public function testStorageControllerMethods() { /** * Tests the behavior of creating conflicting entities. + * + * @todo Add tests for renaming and saving an existing config entity to + * another existing ID. */ - public function testCreatingConflictingEntities() { + public function testUniqueID() { // Create an entity with a label. $entity = entity_create('config_test', array('id' => 'foo', 'label' => 'Foo', 'style' => 'foo')); $entity->save(); // Create an entity with the same ID, but a different label. - $exception = FALSE; try { $entity = entity_create('config_test', array('id' => 'foo', 'label' => 'Bananas')); $entity->save(); + $this->fail('EntityMalformedException was thrown.'); } catch (EntityMalformedException $e) { - $exception = TRUE; + $this->pass('EntityMalformedException was thrown.'); } // Creating an entity with the same machine name should not succeed. $this->assertEqual($entity->label(), 'Foo', 'The entity label was not overwritten.'); $this->assertEqual($entity->style, 'foo', 'The entity style was not overwritten.'); - $this->assertTrue($exception, 'An exception was thrown when creating an entity with a duplicate ID.'); } } diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigImportTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigImportTest.php index 4242bcc..95089f7 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigImportTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigImportTest.php @@ -8,7 +8,6 @@ namespace Drupal\config\Tests; use Drupal\simpletest\DrupalUnitTestBase; -use Drupal\Core\Entity\EntityMalformedException; /** * Tests importing configuration from files into active configuration. @@ -195,17 +194,4 @@ function testUpdated() { $this->assertFalse(config_sync_get_changes($staging, $storage)); } - /** - * Tests enabling a module with a duplicate configuration entity. - */ - function testDuplicate() { - $this->assertEqual(config('config_test.dynamic.default')->get('label'), 'Default', "Configuration object label is 'Default'."); - try { - module_enable(array('config_test_duplicate')); - } - catch (EntityMalformedException $e) { - } - $this->assertEqual(config('config_test.dynamic.default')->get('label'), 'Default', 'Configuration object is not silently overwritten on import.'); - } - } diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigInstallTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigInstallTest.php index b549119..e6e1409 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigInstallTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigInstallTest.php @@ -8,6 +8,7 @@ namespace Drupal\config\Tests; use Drupal\simpletest\DrupalUnitTestBase; +use Drupal\Core\Entity\EntityMalformedException; /** * Tests installation of configuration objects in installation functionality. @@ -64,4 +65,19 @@ function testModuleInstallation() { $this->assertFalse(isset($GLOBALS['hook_config_test']['predelete'])); $this->assertFalse(isset($GLOBALS['hook_config_test']['delete'])); } + + /** + * Tests enabling a module with a duplicate configuration entity. + */ + function testDuplicate() { + $this->enableModules(array('config_test')); + $this->assertEqual(config('config_test.dynamic.default')->get('label'), 'Default', "Configuration object label is 'Default'."); + try { + $this->enableModules(array('config_test_duplicate')); + } + catch (EntityMalformedException $e) { + } + $this->assertEqual(config('config_test.dynamic.default')->get('label'), 'Default', 'Configuration object is not silently overwritten on import.'); + } + } diff --git a/core/modules/config/tests/config_test_duplicate/config/config_test.dynamic.default.yml b/core/modules/config/tests/config_test_duplicate/config/config_test.dynamic.default.yml index 12efb31..deaa6b0 100644 --- a/core/modules/config/tests/config_test_duplicate/config/config_test.dynamic.default.yml +++ b/core/modules/config/tests/config_test_duplicate/config/config_test.dynamic.default.yml @@ -1,2 +1,4 @@ +# This purposefully duplicates config_test.dynamic.default.yml from +# config_test.module, with different values. id: default label: Not default diff --git a/core/modules/config/tests/config_test_duplicate/config_test_duplicate.info b/core/modules/config/tests/config_test_duplicate/config_test_duplicate.info index 491708d..13e0c51 100644 --- a/core/modules/config/tests/config_test_duplicate/config_test_duplicate.info +++ b/core/modules/config/tests/config_test_duplicate/config_test_duplicate.info @@ -1,5 +1,5 @@ name = Duplicate default configuration -package = Core +package = Testing version = VERSION core = 8.x hidden = TRUE