Issue #2927500 by quietone, ridhimaabrol24, kristiaanvandeneynde, phenaproxima, Kristen Pol: Set entity type ID and field name in EntityFieldManager::buildFieldStorageDefinitions
parent
45e5a8aedb
commit
9de43c213a
|
@ -590,6 +590,8 @@ class EntityFieldManager implements EntityFieldManagerInterface {
|
||||||
// proper provider setter. See https://www.drupal.org/node/2225961.
|
// proper provider setter. See https://www.drupal.org/node/2225961.
|
||||||
if ($definition instanceof BaseFieldDefinition) {
|
if ($definition instanceof BaseFieldDefinition) {
|
||||||
$definition->setProvider($module);
|
$definition->setProvider($module);
|
||||||
|
$definition->setName($field_name);
|
||||||
|
$definition->setTargetEntityTypeId($entity_type_id);
|
||||||
}
|
}
|
||||||
$field_definitions[$field_name] = $definition;
|
$field_definitions[$field_name] = $definition;
|
||||||
}
|
}
|
||||||
|
|
|
@ -262,7 +262,15 @@ class EntityFieldManagerTest extends UnitTestCase {
|
||||||
$field_storage_definition = $this->prophesize(FieldStorageDefinitionInterface::class);
|
$field_storage_definition = $this->prophesize(FieldStorageDefinitionInterface::class);
|
||||||
$field_storage_definition->getName()->willReturn('field_storage');
|
$field_storage_definition->getName()->willReturn('field_storage');
|
||||||
|
|
||||||
$definitions = ['field_storage' => $field_storage_definition->reveal()];
|
$base_field_definition = $this->prophesize(BaseFieldDefinition::class);
|
||||||
|
$base_field_definition->setProvider('example_module')->shouldBeCalled();
|
||||||
|
$base_field_definition->setName('base_field')->shouldBeCalled();
|
||||||
|
$base_field_definition->setTargetEntityTypeId('test_entity_type')->shouldBeCalled();
|
||||||
|
|
||||||
|
$definitions = [
|
||||||
|
'base_field' => $base_field_definition->reveal(),
|
||||||
|
'field_storage' => $field_storage_definition->reveal(),
|
||||||
|
];
|
||||||
|
|
||||||
$this->moduleHandler->getImplementations('entity_base_field_info')->willReturn([]);
|
$this->moduleHandler->getImplementations('entity_base_field_info')->willReturn([]);
|
||||||
$this->moduleHandler->getImplementations('entity_field_storage_info')->willReturn(['example_module']);
|
$this->moduleHandler->getImplementations('entity_field_storage_info')->willReturn(['example_module']);
|
||||||
|
@ -271,6 +279,7 @@ class EntityFieldManagerTest extends UnitTestCase {
|
||||||
|
|
||||||
$expected = [
|
$expected = [
|
||||||
'id' => $field_definition,
|
'id' => $field_definition,
|
||||||
|
'base_field' => $base_field_definition->reveal(),
|
||||||
'field_storage' => $field_storage_definition->reveal(),
|
'field_storage' => $field_storage_definition->reveal(),
|
||||||
];
|
];
|
||||||
$this->assertSame($expected, $this->entityFieldManager->getFieldStorageDefinitions('test_entity_type'));
|
$this->assertSame($expected, $this->entityFieldManager->getFieldStorageDefinitions('test_entity_type'));
|
||||||
|
|
Loading…
Reference in New Issue