function ConfigEntityStaticCacheTest::testCacheHit

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStaticCacheTest.php \Drupal\KernelTests\Core\Config\ConfigEntityStaticCacheTest::testCacheHit()
  2. 10 core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStaticCacheTest.php \Drupal\KernelTests\Core\Config\ConfigEntityStaticCacheTest::testCacheHit()
  3. 11.x core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStaticCacheTest.php \Drupal\KernelTests\Core\Config\ConfigEntityStaticCacheTest::testCacheHit()

Tests that the static cache is working.

File

core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStaticCacheTest.php, line 52

Class

ConfigEntityStaticCacheTest
Tests the entity static cache when used by config entities.

Namespace

Drupal\KernelTests\Core\Config

Code

public function testCacheHit() {
    $storage = $this->container
        ->get('entity_type.manager')
        ->getStorage($this->entityTypeId);
    $entity_1 = $storage->load($this->entityId);
    $entity_2 = $storage->load($this->entityId);
    // config_entity_static_cache_test_config_test_load() sets _loadStamp to a
    // random string. If they match, it means $entity_2 was retrieved from the
    // static cache rather than going through a separate load sequence.
    $this->assertSame($entity_1->_loadStamp, $entity_2->_loadStamp);
}

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