diff --git a/core/lib/Drupal/Core/Entity/Plugin/DataType/Deriver/EntityDeriver.php b/core/lib/Drupal/Core/Entity/Plugin/DataType/Deriver/EntityDeriver.php index d02d2a8a66..796b173a4f 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/DataType/Deriver/EntityDeriver.php +++ b/core/lib/Drupal/Core/Entity/Plugin/DataType/Deriver/EntityDeriver.php @@ -2,7 +2,7 @@ namespace Drupal\Core\Entity\Plugin\DataType\Deriver; -use Drupal\Core\Config\Entity\ConfigEntityTypeInterface; +use Drupal\Core\Config\Entity\ConfigEntityInterface; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityTypeBundleInfoInterface; use Drupal\Core\Entity\Plugin\DataType\ConfigEntityAdapter; @@ -89,7 +89,7 @@ public function getDerivativeDefinitions($base_plugin_definition) { $this->derivatives[''] = $base_plugin_definition; // Add definitions for each entity type and bundle. foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) { - $class = $entity_type instanceof ConfigEntityTypeInterface ? ConfigEntityAdapter::class : EntityAdapter::class; + $class = $entity_type->entityClassImplements(ConfigEntityInterface::class) ? ConfigEntityAdapter::class : EntityAdapter::class; $this->derivatives[$entity_type_id] = [ 'class' => $class, 'label' => $entity_type->getLabel(), diff --git a/core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityAdapterTest.php b/core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityAdapterTest.php index 4d24e9511a..d5650be263 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityAdapterTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityAdapterTest.php @@ -15,6 +15,8 @@ * @see \Drupal\Core\Entity\Plugin\DataType\ConfigEntityAdapter * * @group Entity + * + * @coversDefaultClass \Drupal\Core\Entity\Plugin\DataType\ConfigEntityAdapter */ class ConfigEntityAdapterTest extends KernelTestBase { @@ -47,7 +49,7 @@ protected function setUp() { } /** - * Tests that the entity deriver sets the correct class for config entities. + * @covers \Drupal\Core\Entity\Plugin\DataType\Deriver\EntityDeriver::getDerivativeDefinitions */ public function testEntityDeriver() { $definition = \Drupal::typedDataManager()->getDefinition('entity:config_test'); @@ -55,7 +57,7 @@ public function testEntityDeriver() { } /** - * Tests validating a config entity via the adapter. + * @covers ::validate */ public function testValidate() { $adapter = ConfigEntityAdapter::createFromEntity($this->entity); @@ -76,7 +78,7 @@ public function testValidate() { } /** - * Tests getting config entity properties via the adapter. + * @covers ::getProperties */ public function testGetProperties() { $expected_properties = [ @@ -102,9 +104,9 @@ public function testGetProperties() { } /** - * Tests getting a config entity property via the adapter. + * @covers ::getValue */ - public function testGetProperty() { + public function testGetValue() { $adapter = ConfigEntityAdapter::createFromEntity($this->entity); $this->assertEquals($this->entity->weight, $adapter->get('weight')->getValue()); $this->assertEquals($this->entity->id(), $adapter->get('id')->getValue()); @@ -112,9 +114,9 @@ public function testGetProperty() { } /** - * Tests setting a config entity property via the adapter. + * @covers ::set */ - public function testSetProperty() { + public function testSet() { $adapter = ConfigEntityAdapter::createFromEntity($this->entity); // Get the value via typed data to ensure that the typed representation is // updated correctly when the value is set. @@ -127,7 +129,7 @@ public function testSetProperty() { } /** - * Tests getting the config entity as a string via the adapter. + * @covers ::getString */ public function testGetString() { $adapter = ConfigEntityAdapter::createFromEntity($this->entity); @@ -135,7 +137,7 @@ public function testGetString() { } /** - * Tests applying default values to the config entity is not supported. + * @covers ::applyDefaultValue */ public function testApplyDefaultValue() { $this->setExpectedException(\BadMethodCallException::class, 'Method not supported');