function EntityFieldManagerTest::testGetFieldDefinitionsProvider
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php \Drupal\Tests\Core\Entity\EntityFieldManagerTest::testGetFieldDefinitionsProvider()
- 8.9.x core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php \Drupal\Tests\Core\Entity\EntityFieldManagerTest::testGetFieldDefinitionsProvider()
- 11.x core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php \Drupal\Tests\Core\Entity\EntityFieldManagerTest::testGetFieldDefinitionsProvider()
Tests that getFieldDefinitions() method sets the 'provider' definition key.
@covers ::getFieldDefinitions @covers ::buildBundleFieldDefinitions
File
-
core/
tests/ Drupal/ Tests/ Core/ Entity/ EntityFieldManagerTest.php, line 545
Class
- EntityFieldManagerTest
- @coversDefaultClass \Drupal\Core\Entity\EntityFieldManager @group Entity
Namespace
Drupal\Tests\Core\EntityCode
public function testGetFieldDefinitionsProvider() : void {
$this->setUpEntityWithFieldDefinition(TRUE);
$module = 'entity_field_manager_test_module';
// @todo Mock FieldDefinitionInterface once it exposes a proper provider
// setter. See https://www.drupal.org/node/2346329.
$field_definition = $this->prophesize(BaseFieldDefinition::class);
// We expect two calls as the field definition will be returned from both
// base and bundle entity field info hook implementations.
$field_definition->getProvider()
->shouldBeCalled();
$field_definition->setProvider($module)
->shouldBeCalledTimes(2);
$field_definition->setName(0)
->shouldBeCalledTimes(2);
$field_definition->setTargetEntityTypeId('test_entity_type')
->shouldBeCalled();
$field_definition->setTargetBundle(NULL)
->shouldBeCalled();
$field_definition->setTargetBundle('test_bundle')
->shouldBeCalled();
$this->moduleHandler
->invokeAllWith(Argument::type('string'), Argument::any())
->will(function ($arguments) use ($field_definition, $module) {
[
$hook,
$callback,
] = $arguments;
$callback(function () use ($field_definition) {
return [
$field_definition->reveal(),
];
}, $module);
});
$this->entityFieldManager
->getFieldDefinitions('test_entity_type', 'test_bundle');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.