1 | <?php |
||
13 | class BlackholeCacheItemPoolDecoratorTest extends TestCase |
||
14 | { |
||
15 | /** |
||
16 | * Asserts that blackhole pool will always report a cache miss. |
||
17 | */ |
||
18 | public function testIsHit() |
||
19 | { |
||
20 | $cachePool = $this->getCachePool(['test' => 'test']); |
||
21 | |||
22 | $blackholePool = new BlackholeCacheItemPoolDecorator($cachePool); |
||
23 | |||
24 | $this->assertTrue($cachePool->getItem('test')->isHit()); |
||
25 | $this->assertFalse($blackholePool->getItem('test')->isHit()); |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * Asserts that item returned by the blackhole pool is the correct type. |
||
30 | */ |
||
31 | public function testGetItem() |
||
32 | { |
||
33 | $cachePool = $this->getCachePool(['test' => 'test']); |
||
34 | $blackholePool = new BlackholeCacheItemPoolDecorator($cachePool); |
||
35 | |||
36 | $this->assertInstanceOf(BlackholeCacheItemDecorator::class, $blackholePool->getItem('test')); |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * Asserts that items returned by the blackhole pool are the correct type. |
||
41 | */ |
||
42 | public function testGetItems() |
||
43 | { |
||
44 | $cachePool = $this->getCachePool(['test1' => 'test1', 'test2' => 'test2']); |
||
45 | $blackholePool = new BlackholeCacheItemPoolDecorator($cachePool); |
||
46 | |||
47 | foreach ($blackholePool->getItems(['test1', 'test2']) as $item) { |
||
48 | $this->assertInstanceOf(BlackholeCacheItemDecorator::class, $item); |
||
49 | } |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * Asserts that decorated item returned by the blackhole pool is of the correct type. |
||
54 | */ |
||
55 | public function testGetDecoratedItem() |
||
56 | { |
||
57 | $cachePool = $this->getCachePool(['test' => 'test']); |
||
58 | $cacheItem = $cachePool->getItem('test'); |
||
59 | $blackholePool = new BlackholeCacheItemPoolDecorator($cachePool); |
||
60 | $blackholeItem = $blackholePool->getItem('test'); |
||
61 | |||
62 | $this->assertInstanceOf(get_class($cacheItem), $blackholeItem->getDecoratedItem()); |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * Returns an implementation of the CacheItemPoolInterface |
||
67 | * initialized with the values provided in the array. |
||
68 | * |
||
69 | * @throws \Psr\Cache\InvalidArgumentException |
||
70 | */ |
||
71 | private function getCachePool(array $values): CacheItemPoolInterface |
||
82 | } |
||
83 |