protected function BaseFieldDefinitionTestBase::setUp in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/Field/BaseFieldDefinitionTestBase.php \Drupal\Tests\Core\Field\BaseFieldDefinitionTestBase::setUp()
Overrides UnitTestCase::setUp
File
- core/
tests/ Drupal/ Tests/ Core/ Field/ BaseFieldDefinitionTestBase.php, line 30 - Contains \Drupal\Tests\Core\Field\BaseFieldDefinitionTestBase.
Class
- BaseFieldDefinitionTestBase
- Provides setup method for testing base field definitions.
Namespace
Drupal\Tests\Core\FieldCode
protected function setUp() {
// getModuleAndPath() returns an array of the module name and directory.
list($module_name, $module_dir) = $this
->getModuleAndPath();
$namespaces = new \ArrayObject();
$namespaces["Drupal\\{$module_name}"] = $module_dir . '/src';
$module_handler = $this
->getMock('Drupal\\Core\\Extension\\ModuleHandlerInterface');
$module_handler
->expects($this
->once())
->method('moduleExists')
->with($module_name)
->will($this
->returnValue(TRUE));
$typed_data_manager = $this
->getMockBuilder('\\Drupal\\Core\\TypedData\\TypedDataManager')
->disableOriginalConstructor()
->getMock();
$plugin_manager = new FieldTypePluginManager($namespaces, $this
->getMock('Drupal\\Core\\Cache\\CacheBackendInterface'), $module_handler, $typed_data_manager);
$container = new ContainerBuilder();
$container
->set('plugin.manager.field.field_type', $plugin_manager);
// The 'string_translation' service is used by the @Translation annotation.
$container
->set('string_translation', $this
->getStringTranslationStub());
\Drupal::setContainer($container);
$this->definition = BaseFieldDefinition::create($this
->getPluginId());
}