function EntityFieldManagerTest::setUpEntityTypeDefinitions

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

Sets up the entity type manager to be tested.

Parameters

\Drupal\Core\Entity\EntityTypeInterface[]|\Prophecy\Prophecy\ProphecyInterface[] $definitions: (optional) An array of entity type definitions.

6 calls to EntityFieldManagerTest::setUpEntityTypeDefinitions()
EntityFieldManagerTest::setUpEntityWithFieldDefinition in core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php
Prepares an entity that defines a field definition.
EntityFieldManagerTest::testClearCachedFieldDefinitions in core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php
Tests the clearCachedFieldDefinitions() method.
EntityFieldManagerTest::testGetExtraFields in core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php
@covers ::getExtraFields
EntityFieldManagerTest::testGetFieldMap in core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php
@covers ::getFieldMap
EntityFieldManagerTest::testGetFieldMapByFieldType in core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php
@covers ::getFieldMapByFieldType

... See full list

File

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

Class

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

Namespace

Drupal\Tests\Core\Entity

Code

protected function setUpEntityTypeDefinitions($definitions = []) {
    foreach ($definitions as $key => $entity_type) {
        // \Drupal\Core\Entity\EntityTypeInterface::getLinkTemplates() is called
        // by \Drupal\Core\Entity\EntityTypeManager::processDefinition() so it must
        // always be mocked.
        $entity_type->getLinkTemplates()
            ->willReturn([]);
        $definitions[$key] = $entity_type->reveal();
    }
    $this->entityTypeManager
        ->getDefinition(Argument::type('string'))
        ->will(function ($args) use ($definitions) {
        if (isset($definitions[$args[0]])) {
            return $definitions[$args[0]];
        }
        throw new PluginNotFoundException($args[0]);
    });
    $this->entityTypeManager
        ->getDefinition(Argument::type('string'), FALSE)
        ->will(function ($args) use ($definitions) {
        if (isset($definitions[$args[0]])) {
            return $definitions[$args[0]];
        }
    });
    $this->entityTypeManager
        ->getDefinitions()
        ->willReturn($definitions);
}

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