function FieldTypePluginManagerTest::setUp

Same name and namespace in other branches
  1. 10 core/tests/Drupal/Tests/Core/Field/FieldTypePluginManagerTest.php \Drupal\Tests\Core\Field\FieldTypePluginManagerTest::setUp()
  2. main core/tests/Drupal/Tests/Core/Field/FieldTypePluginManagerTest.php \Drupal\Tests\Core\Field\FieldTypePluginManagerTest::setUp()

Overrides UnitTestCase::setUp

File

core/tests/Drupal/Tests/Core/Field/FieldTypePluginManagerTest.php, line 58

Class

FieldTypePluginManagerTest
Tests Drupal\Core\Field\FieldTypePluginManager.

Namespace

Drupal\Tests\Core\Field

Code

protected function setUp() : void {
  parent::setUp();
  $container = new ContainerBuilder();
  $current_user = $this->prophesize(AccountInterface::class);
  $container->set('current_user', $current_user->reveal());
  $container->set('string_translation', $this->getStringTranslationStub());
  \Drupal::setContainer($container);
  $cache_backend = $this->prophesize(CacheBackendInterface::class);
  $this->moduleHandler = $this->prophesize(ModuleHandlerInterface::class);
  $this->moduleHandler
    ->alter('field_info', Argument::any())
    ->willReturn(NULL);
  $typed_data_manager = $this->prophesize(TypedDataManager::class);
  $this->fieldTypeCategoryManager = $this->prophesize(FieldTypeCategoryManagerInterface::class);
  $this->fieldTypeManager = new FieldTypePluginManager(new \ArrayObject(), $cache_backend->reveal(), $this->moduleHandler
    ->reveal(), $typed_data_manager->reveal(), $this->fieldTypeCategoryManager
    ->reveal());
  $this->fieldTypeManager
    ->setStringTranslation($this->getStringTranslationStub());
  $this->discovery = $this->prophesize(DiscoveryInterface::class);
  $property = new \ReflectionProperty(FieldTypePluginManager::class, 'discovery');
  $property->setValue($this->fieldTypeManager, $this->discovery
    ->reveal());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.