function EntityFieldManagerTest::testGetFieldMapFromCache

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

@covers ::getFieldMap

File

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

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

public function testGetFieldMapFromCache() : void {
    $expected = [
        'test_entity_type' => [
            'id' => [
                'type' => 'integer',
                'bundles' => [
                    'first_bundle' => 'first_bundle',
                    'second_bundle' => 'second_bundle',
                ],
            ],
            'by_bundle' => [
                'type' => 'string',
                'bundles' => [
                    'second_bundle' => 'second_bundle',
                ],
            ],
        ],
    ];
    $this->setUpEntityTypeDefinitions();
    $this->cacheBackend
        ->get('entity_field_map')
        ->willReturn((object) [
        'data' => $expected,
    ]);
    // Call the field map twice to make sure the static cache works.
    $this->assertEquals($expected, $this->entityFieldManager
        ->getFieldMap());
    $this->assertEquals($expected, $this->entityFieldManager
        ->getFieldMap());
}

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