diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php index 2d2beb5..8a278ae 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php @@ -290,7 +290,7 @@ public function toArray() { $properties[$export_name] = $this->get($property_name); } } - if (empty($this->thirdPartySettings)) { + if (empty($this->third_party_settings)) { unset($properties['third_party_settings']); } return $properties; diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php index 71bc435..5ba9f53 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php @@ -15,7 +15,7 @@ /** * Provides an implementation of a configuration entity type and its metadata. */ -class ConfigEntityType extends EntityType { +class ConfigEntityType extends EntityType implements ConfigEntityTypeInterface { /** * Length limit of the configuration entity prefix. @@ -189,11 +189,7 @@ protected function checkStorageClass($class) { } /** - * Gets the config entity properties to export if declared on the annotation. - * - * @return array|bool - * The properties to export or FALSE if they can not be determine from the - * config entity type annotation. + * {@inheritdoc} */ public function getPropertiesToExport() { if (!empty($this->config_export)) { diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityTypeInterface.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityTypeInterface.php new file mode 100644 index 0000000..d0aaecf --- /dev/null +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityTypeInterface.php @@ -0,0 +1,26 @@ +assertEqual($definition, $expected, 'Retrieved the right metadata for the first effect of image.style.medium'); + $a = \Drupal::config('config_test.dynamic.third_party'); $test = \Drupal::service('config.typed')->get('config_test.dynamic.third_party')->get('third_party_settings.config_schema_test'); $definition = $test->getDataDefinition()->toArray(); $expected = array(); diff --git a/core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php b/core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php index 6904110..2bce97d 100644 --- a/core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php +++ b/core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php @@ -22,7 +22,7 @@ class FieldConfigEntityUnitTest extends UnitTestCase { /** * The entity type used for testing. * - * @var \Drupal\Core\Entity\EntityTypeInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Drupal\Core\Config\Entity\ConfigEntityTypeInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $entityType; @@ -73,7 +73,7 @@ class FieldConfigEntityUnitTest extends UnitTestCase { */ protected function setUp() { $this->entityTypeId = $this->randomMachineName(); - $this->entityType = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface'); + $this->entityType = $this->getMock('\Drupal\Core\Config\Entity\ConfigEntityTypeInterface'); $this->entityManager = $this->getMock('\Drupal\Core\Entity\EntityManagerInterface'); diff --git a/core/modules/field/tests/src/Unit/FieldStorageConfigEntityUnitTest.php b/core/modules/field/tests/src/Unit/FieldStorageConfigEntityUnitTest.php index cd05b9b..424424a 100644 --- a/core/modules/field/tests/src/Unit/FieldStorageConfigEntityUnitTest.php +++ b/core/modules/field/tests/src/Unit/FieldStorageConfigEntityUnitTest.php @@ -19,13 +19,6 @@ class FieldStorageConfigEntityUnitTest extends UnitTestCase { /** - * The entity type used for testing. - * - * @var \Drupal\Core\Entity\EntityTypeInterface|\PHPUnit_Framework_MockObject_MockObject - */ - protected $entityType; - - /** * The entity manager used for testing. * * @var \Drupal\Core\Entity\EntityManagerInterface|\PHPUnit_Framework_MockObject_MockObject @@ -64,7 +57,7 @@ protected function setUp() { */ public function testCalculateDependencies() { // Create a mock entity type for FieldStorageConfig. - $fieldStorageConfigentityType = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface'); + $fieldStorageConfigentityType = $this->getMock('\Drupal\Core\Config\Entity\ConfigEntityTypeInterface'); $fieldStorageConfigentityType->expects($this->any()) ->method('getProvider') ->will($this->returnValue('field')); diff --git a/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php index 9456d33..fe1e1a1 100644 --- a/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php @@ -30,7 +30,7 @@ class ConfigEntityBaseUnitTest extends UnitTestCase { /** * The entity type used for testing. * - * @var \Drupal\Core\Entity\EntityTypeInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Drupal\Core\Config\Entity\ConfigEntityTypeInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $entityType; @@ -102,7 +102,7 @@ protected function setUp() { ); $this->entityTypeId = $this->randomMachineName(); $this->provider = $this->randomMachineName(); - $this->entityType = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface'); + $this->entityType = $this->getMock('\Drupal\Core\Config\Entity\ConfigEntityTypeInterface'); $this->entityType->expects($this->any()) ->method('getProvider') ->will($this->returnValue($this->provider)); @@ -456,9 +456,26 @@ public function testSort() { * @covers ::toArray */ public function testToArray() { + $this->typedConfigManager->expects($this->never()) + ->method('getDefinition'); + $this->entityType->expects($this->any()) + ->method('getPropertiesToExport') + ->willReturn(['id' => 'configId', 'dependencies' => 'dependencies']); + $properties = $this->entity->toArray(); + $this->assertInternalType('array', $properties); + $this->assertEquals(array('configId' => $this->entity->id(), 'dependencies' => array()), $properties); + } + + /** + * @covers ::toArray + */ + public function testToArraySchemaFallback() { $this->typedConfigManager->expects($this->once()) ->method('getDefinition') ->will($this->returnValue(array('mapping' => array('id' => '', 'dependencies' => '')))); + $this->entityType->expects($this->any()) + ->method('getPropertiesToExport') + ->willReturn([]); $properties = $this->entity->toArray(); $this->assertInternalType('array', $properties); $this->assertEquals(array('id' => $this->entity->id(), 'dependencies' => array()), $properties); @@ -470,6 +487,9 @@ public function testToArray() { * @expectedException \Drupal\Core\Config\Schema\SchemaIncompleteException */ public function testToArrayFallback() { + $this->entityType->expects($this->any()) + ->method('getPropertiesToExport') + ->willReturn([]); $this->entity->toArray(); } diff --git a/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php index 2302eaa..e0083e4 100644 --- a/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php +++ b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php @@ -22,7 +22,7 @@ class ConfigEntityStorageTest extends UnitTestCase { /** * The entity type. * - * @var \Drupal\Core\Entity\EntityTypeInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Drupal\Core\Config\Entity\ConfigEntityTypeInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $entityType; @@ -111,7 +111,7 @@ class ConfigEntityStorageTest extends UnitTestCase { protected function setUp() { parent::setUp(); - $this->entityType = $this->getMock('Drupal\Core\Entity\EntityTypeInterface'); + $this->entityType = $this->getMock('Drupal\Core\Config\Entity\ConfigEntityTypeInterface'); $this->entityTypeId = 'test_entity_type'; $this->entityType->expects($this->any()) ->method('getKey')