function EntityFieldManagerTest::testGetFieldDefinitionsProvider
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php \Drupal\Tests\Core\Entity\EntityFieldManagerTest::testGetFieldDefinitionsProvider()
- 10 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 470
Class
- EntityFieldManagerTest
- @coversDefaultClass \Drupal\Core\Entity\EntityFieldManager @group Entity
Namespace
Drupal\Tests\Core\EntityCode
public function testGetFieldDefinitionsProvider() {
$this->setUpEntityWithFieldDefinition(TRUE);
$module = 'entity_manager_test_module';
// @todo Mock FieldDefinitionInterface once it exposes a proper provider
// setter. See https://www.drupal.org/node/2225961.
$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
->getImplementations(Argument::type('string'))
->willReturn([
$module,
]);
$this->moduleHandler
->invoke($module, 'entity_base_field_info', [
$this->entityType,
])
->willReturn([
$field_definition->reveal(),
]);
$this->moduleHandler
->invoke($module, 'entity_bundle_field_info', Argument::type('array'))
->willReturn([
$field_definition->reveal(),
]);
$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.