Upgraded drupal core with security updates
[yaffs-website] / web / core / tests / Drupal / Tests / Core / Config / CachedStorageTest.php
1 <?php
2
3 namespace Drupal\Tests\Core\Config;
4
5 use Drupal\Tests\UnitTestCase;
6 use Drupal\Core\Config\CachedStorage;
7 use Drupal\Core\Cache\NullBackend;
8
9 /**
10  * Tests the interaction of cache and file storage in CachedStorage.
11  *
12  * @group Config
13  */
14 class CachedStorageTest extends UnitTestCase {
15
16   /**
17    * @var \Drupal\Core\Cache\CacheFactoryInterface|\PHPUnit_Framework_MockObject_MockObject
18    */
19   protected $cacheFactory;
20
21   /**
22    * Test listAll static cache.
23    */
24   public function testListAllStaticCache() {
25     $prefix = __FUNCTION__;
26     $storage = $this->getMock('Drupal\Core\Config\StorageInterface');
27
28     $response = ["$prefix." . $this->randomMachineName(), "$prefix." . $this->randomMachineName()];
29     $storage->expects($this->once())
30       ->method('listAll')
31       ->with($prefix)
32       ->will($this->returnValue($response));
33
34     $cache = new NullBackend(__FUNCTION__);
35
36     $cachedStorage = new CachedStorage($storage, $cache);
37     $this->assertEquals($response, $cachedStorage->listAll($prefix));
38     $this->assertEquals($response, $cachedStorage->listAll($prefix));
39   }
40
41 }