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()

Overrides UnitTestCase::setUp

File

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

Class

FieldTypePluginManagerTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Field%21FieldTypePluginManager.php/class/FieldTypePluginManager/11.x" title="Plugin manager for &#039;field type&#039; plugins." class="local">\Drupal\Core\Field\FieldTypePluginManager</a> @group Field

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->setAccessible(TRUE);
    $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.