|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Doctrine\Tests\Common\Cache; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\Common\Cache\ApcCache; |
|
6
|
|
|
use Doctrine\Common\Cache\ArrayCache; |
|
7
|
|
|
use Doctrine\Common\Cache\ChainCache; |
|
8
|
|
|
|
|
9
|
|
|
class ChainCacheTest extends CacheTest |
|
10
|
|
|
{ |
|
11
|
|
|
protected function _getCacheDriver() |
|
12
|
|
|
{ |
|
13
|
|
|
return new ChainCache(array(new ArrayCache())); |
|
14
|
|
|
} |
|
15
|
|
|
|
|
16
|
|
|
public function testLifetime() |
|
17
|
|
|
{ |
|
18
|
|
|
$this->markTestSkipped('The ChainCache test uses ArrayCache which does not implement TTL currently.'); |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
public function testGetStats() |
|
22
|
|
|
{ |
|
23
|
|
|
$cache = $this->_getCacheDriver(); |
|
24
|
|
|
$stats = $cache->getStats(); |
|
25
|
|
|
|
|
26
|
|
|
$this->assertInternalType('array', $stats); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
public function testOnlyFetchFirstOne() |
|
30
|
|
|
{ |
|
31
|
|
|
$cache1 = new ArrayCache(); |
|
32
|
|
|
$cache2 = $this->getMockForAbstractClass('Doctrine\Common\Cache\CacheProvider'); |
|
33
|
|
|
|
|
34
|
|
|
$cache2->expects($this->never())->method('doFetch'); |
|
35
|
|
|
|
|
36
|
|
|
$chainCache = new ChainCache(array($cache1, $cache2)); |
|
|
|
|
|
|
37
|
|
|
$chainCache->save('id', 'bar'); |
|
38
|
|
|
|
|
39
|
|
|
$this->assertEquals('bar', $chainCache->fetch('id')); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function testFetchPropagateToFastestCache() |
|
43
|
|
|
{ |
|
44
|
|
|
$cache1 = new ArrayCache(); |
|
45
|
|
|
$cache2 = new ArrayCache(); |
|
46
|
|
|
|
|
47
|
|
|
$cache2->save('bar', 'value'); |
|
48
|
|
|
|
|
49
|
|
|
$chainCache = new ChainCache(array($cache1, $cache2)); |
|
50
|
|
|
|
|
51
|
|
|
$this->assertFalse($cache1->contains('bar')); |
|
52
|
|
|
|
|
53
|
|
|
$result = $chainCache->fetch('bar'); |
|
54
|
|
|
|
|
55
|
|
|
$this->assertEquals('value', $result); |
|
56
|
|
|
$this->assertTrue($cache2->contains('bar')); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
public function testNamespaceIsPropagatedToAllProviders() |
|
60
|
|
|
{ |
|
61
|
|
|
$cache1 = new ArrayCache(); |
|
62
|
|
|
$cache2 = new ArrayCache(); |
|
63
|
|
|
|
|
64
|
|
|
$chainCache = new ChainCache(array($cache1, $cache2)); |
|
65
|
|
|
$chainCache->setNamespace('bar'); |
|
66
|
|
|
|
|
67
|
|
|
$this->assertEquals('bar', $cache1->getNamespace()); |
|
68
|
|
|
$this->assertEquals('bar', $cache2->getNamespace()); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
public function testDeleteToAllProviders() |
|
72
|
|
|
{ |
|
73
|
|
|
$cache1 = $this->getMockForAbstractClass('Doctrine\Common\Cache\CacheProvider'); |
|
74
|
|
|
$cache2 = $this->getMockForAbstractClass('Doctrine\Common\Cache\CacheProvider'); |
|
75
|
|
|
|
|
76
|
|
|
$cache1->expects($this->once())->method('doDelete'); |
|
77
|
|
|
$cache2->expects($this->once())->method('doDelete'); |
|
78
|
|
|
|
|
79
|
|
|
$chainCache = new ChainCache(array($cache1, $cache2)); |
|
80
|
|
|
$chainCache->delete('bar'); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
public function testFlushToAllProviders() |
|
84
|
|
|
{ |
|
85
|
|
|
$cache1 = $this->getMockForAbstractClass('Doctrine\Common\Cache\CacheProvider'); |
|
86
|
|
|
$cache2 = $this->getMockForAbstractClass('Doctrine\Common\Cache\CacheProvider'); |
|
87
|
|
|
|
|
88
|
|
|
$cache1->expects($this->once())->method('doFlush'); |
|
89
|
|
|
$cache2->expects($this->once())->method('doFlush'); |
|
90
|
|
|
|
|
91
|
|
|
$chainCache = new ChainCache(array($cache1, $cache2)); |
|
92
|
|
|
$chainCache->flushAll(); |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
protected function isSharedStorage() |
|
96
|
|
|
{ |
|
97
|
|
|
return false; |
|
98
|
|
|
} |
|
99
|
|
|
} |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: