function BaseFieldDefinitionTest::setUp
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Entity/BaseFieldDefinitionTest.php \Drupal\Tests\Core\Entity\BaseFieldDefinitionTest::setUp()
- 10 core/tests/Drupal/Tests/Core/Entity/BaseFieldDefinitionTest.php \Drupal\Tests\Core\Entity\BaseFieldDefinitionTest::setUp()
- 11.x core/tests/Drupal/Tests/Core/Entity/BaseFieldDefinitionTest.php \Drupal\Tests\Core\Entity\BaseFieldDefinitionTest::setUp()
Overrides UnitTestCase::setUp
File
-
core/
tests/ Drupal/ Tests/ Core/ Entity/ BaseFieldDefinitionTest.php, line 37
Class
- BaseFieldDefinitionTest
- Unit test for BaseFieldDefinition.
Namespace
Drupal\Tests\Core\EntityCode
protected function setUp() {
// Mock the field type manager and place it in the container.
$field_type_manager = $this->createMock('Drupal\\Core\\Field\\FieldTypePluginManagerInterface');
$this->fieldType = $this->randomMachineName();
$this->fieldTypeDefinition = [
'id' => $this->fieldType,
'storage_settings' => [
'some_setting' => 'value 1',
],
'field_settings' => [
'some_instance_setting' => 'value 2',
],
];
$field_type_manager->expects($this->any())
->method('getDefinitions')
->will($this->returnValue([
$this->fieldType => $this->fieldTypeDefinition,
]));
$field_type_manager->expects($this->any())
->method('getDefinition')
->with($this->fieldType)
->will($this->returnValue($this->fieldTypeDefinition));
$field_type_manager->expects($this->any())
->method('getDefaultStorageSettings')
->with($this->fieldType)
->will($this->returnValue($this->fieldTypeDefinition['storage_settings']));
$field_type_manager->expects($this->any())
->method('getDefaultFieldSettings')
->with($this->fieldType)
->will($this->returnValue($this->fieldTypeDefinition['field_settings']));
$container = new ContainerBuilder();
$container->set('plugin.manager.field.field_type', $field_type_manager);
\Drupal::setContainer($container);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.