public function EntityFieldManagerTest::testGetFieldDefinitionsProvider in Zircon Profile 8
Same name and namespace in other branches
- 8.0 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 473 - Contains \Drupal\Tests\Core\Entity\EntityFieldManagerTest.
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');
}