diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityUnitTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityUnitTest.php index d64c73a..cf74af5 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityUnitTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityUnitTest.php @@ -8,6 +8,7 @@ namespace Drupal\config\Tests; use Drupal\simpletest\DrupalUnitTestBase; +use Drupal\Core\Entity\EntityMalformedException; /** * Unit tests for configuration controllers and objects. @@ -40,4 +41,25 @@ public function testStorageControllerMethods() { $this->assertIdentical($controller->getConfigPrefix(), $expected); } + /** + * Tests the behavior of creating conflicting entities. + */ + public function testCreatingConflictingEntities() { + // 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. + try { + $entity = entity_create('config_test', array('id' => 'foo', 'label' => 'Bananas')); + $entity->save(); + } + catch (EntityMalformedException $e) { + $this->pass('A conflicting entity was not saved.'); + } + // 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.'); + } + }