public function EntityFieldManagerTest::testGetFieldStorageDefinitions in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php \Drupal\Tests\Core\Entity\EntityFieldManagerTest::testGetFieldStorageDefinitions()
Tests the getFieldStorageDefinitions() method.
@covers ::getFieldStorageDefinitions @covers ::buildFieldStorageDefinitions
File
- core/
tests/ Drupal/ Tests/ Core/ Entity/ EntityFieldManagerTest.php, line 260 - Contains \Drupal\Tests\Core\Entity\EntityFieldManagerTest.
Class
- EntityFieldManagerTest
- @coversDefaultClass \Drupal\Core\Entity\EntityFieldManager @group Entity
Namespace
Drupal\Tests\Core\EntityCode
public function testGetFieldStorageDefinitions() {
$field_definition = $this
->setUpEntityWithFieldDefinition(TRUE);
$field_storage_definition = $this
->prophesize(FieldStorageDefinitionInterface::class);
$field_storage_definition
->getName()
->willReturn('field_storage');
$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_field_storage_info')
->willReturn([
'example_module',
]);
$this->moduleHandler
->invoke('example_module', 'entity_field_storage_info', [
$this->entityType,
])
->willReturn($definitions);
$this->moduleHandler
->alter('entity_field_storage_info', $definitions, $this->entityType)
->willReturn(NULL);
$expected = [
'id' => $field_definition,
'base_field' => $base_field_definition
->reveal(),
'field_storage' => $field_storage_definition
->reveal(),
];
$this
->assertSame($expected, $this->entityFieldManager
->getFieldStorageDefinitions('test_entity_type'));
}