function CachedStorageTest::testListAllStaticCache

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

Tests listAll static cache.

File

core/tests/Drupal/Tests/Core/Config/CachedStorageTest.php, line 26

Class

CachedStorageTest
Tests the interaction of cache and file storage in CachedStorage.

Namespace

Drupal\Tests\Core\Config

Code

public function testListAllStaticCache() : void {
    $prefix = __FUNCTION__;
    $storage = $this->createMock('Drupal\\Core\\Config\\StorageInterface');
    $response = [
        "{$prefix}." . $this->randomMachineName(),
        "{$prefix}." . $this->randomMachineName(),
    ];
    $storage->expects($this->once())
        ->method('listAll')
        ->with($prefix)
        ->willReturn($response);
    $cache = new NullBackend(__FUNCTION__);
    $cachedStorage = new CachedStorage($storage, $cache);
    $this->assertEquals($response, $cachedStorage->listAll($prefix));
    $this->assertEquals($response, $cachedStorage->listAll($prefix));
}

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