function EntityFieldManagerTest::testGetFieldMapFromCache

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php \Drupal\Tests\Core\Entity\EntityFieldManagerTest::testGetFieldMapFromCache()
  2. 10 core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php \Drupal\Tests\Core\Entity\EntityFieldManagerTest::testGetFieldMapFromCache()
  3. 11.x 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 \Drupal\Core\Entity\EntityFieldManager @group Entity

Namespace

Drupal\Tests\Core\Entity

Code

public function testGetFieldMapFromCache() {
    $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.