function EntityFieldManagerTest::setUp

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php \Drupal\Tests\Core\Entity\EntityFieldManagerTest::setUp()
  2. 8.9.x core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php \Drupal\Tests\Core\Entity\EntityFieldManagerTest::setUp()
  3. 10 core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php \Drupal\Tests\Core\Entity\EntityFieldManagerTest::setUp()

Overrides UnitTestCase::setUp

File

core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php, line 152

Class

EntityFieldManagerTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Entity%21EntityFieldManager.php/class/EntityFieldManager/11.x" title="Manages the discovery of entity fields." class="local">\Drupal\Core\Entity\EntityFieldManager</a> @group Entity

Namespace

Drupal\Tests\Core\Entity

Code

protected function setUp() : void {
    parent::setUp();
    $this->container = $this->prophesize(ContainerInterface::class);
    \Drupal::setContainer($this->container
        ->reveal());
    $this->typedDataManager = $this->prophesize(TypedDataManagerInterface::class);
    $this->typedDataManager
        ->getDefinition('field_item:boolean')
        ->willReturn([
        'class' => BooleanItem::class,
    ]);
    $this->container
        ->get('typed_data_manager')
        ->willReturn($this->typedDataManager
        ->reveal());
    $this->moduleHandler = $this->prophesize(ModuleHandlerInterface::class);
    $this->moduleHandler
        ->alter('entity_base_field_info', Argument::type('array'), Argument::any())
        ->willReturn(NULL);
    $this->moduleHandler
        ->alter('entity_bundle_field_info', Argument::type('array'), Argument::any(), Argument::type('string'))
        ->willReturn(NULL);
    $this->cacheBackend = $this->prophesize(CacheBackendInterface::class);
    $this->cacheTagsInvalidator = $this->prophesize(CacheTagsInvalidatorInterface::class);
    $language = new Language([
        'id' => 'en',
    ]);
    $this->languageManager = $this->prophesize(LanguageManagerInterface::class);
    $this->languageManager
        ->getCurrentLanguage()
        ->willReturn($language);
    $this->languageManager
        ->getLanguages()
        ->willReturn([
        'en' => (object) [
            'id' => 'en',
        ],
    ]);
    $this->keyValueFactory = $this->prophesize(KeyValueFactoryInterface::class);
    $this->entityTypeManager = $this->prophesize(EntityTypeManagerInterface::class);
    $this->entityTypeRepository = $this->prophesize(EntityTypeRepositoryInterface::class);
    $this->entityTypeBundleInfo = $this->prophesize(EntityTypeBundleInfoInterface::class);
    $this->entityDisplayRepository = $this->prophesize(EntityDisplayRepositoryInterface::class);
    $this->entityLastInstalledSchemaRepository = $this->prophesize(EntityLastInstalledSchemaRepositoryInterface::class);
    $this->entityFieldManager = new TestEntityFieldManager($this->entityTypeManager
        ->reveal(), $this->entityTypeBundleInfo
        ->reveal(), $this->entityDisplayRepository
        ->reveal(), $this->typedDataManager
        ->reveal(), $this->languageManager
        ->reveal(), $this->keyValueFactory
        ->reveal(), $this->moduleHandler
        ->reveal(), $this->cacheBackend
        ->reveal(), $this->entityLastInstalledSchemaRepository
        ->reveal());
}

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