scratch – Blame information for rev
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
115 | office | 1 | <?php |
2 | |||
3 | namespace Doctrine\Tests\Common\Cache; |
||
4 | |||
5 | use Doctrine\Common\Cache\ArrayCache; |
||
6 | use Doctrine\Common\Cache\Cache; |
||
7 | |||
8 | class ArrayCacheTest extends CacheTest |
||
9 | { |
||
10 | protected function _getCacheDriver() |
||
11 | { |
||
12 | return new ArrayCache(); |
||
13 | } |
||
14 | |||
15 | public function testGetStats() |
||
16 | { |
||
17 | $cache = $this->_getCacheDriver(); |
||
18 | $cache->fetch('test1'); |
||
19 | $cache->fetch('test2'); |
||
20 | $cache->fetch('test3'); |
||
21 | |||
22 | $cache->save('test1', 123); |
||
23 | $cache->save('test2', 123); |
||
24 | |||
25 | $cache->fetch('test1'); |
||
26 | $cache->fetch('test2'); |
||
27 | $cache->fetch('test3'); |
||
28 | |||
29 | $stats = $cache->getStats(); |
||
30 | $this->assertEquals(2, $stats[Cache::STATS_HITS]); |
||
31 | $this->assertEquals(5, $stats[Cache::STATS_MISSES]); // +1 for internal call to DoctrineNamespaceCacheKey |
||
32 | $this->assertNotNull($stats[Cache::STATS_UPTIME]); |
||
33 | $this->assertNull($stats[Cache::STATS_MEMORY_USAGE]); |
||
34 | $this->assertNull($stats[Cache::STATS_MEMORY_AVAILABLE]); |
||
35 | |||
36 | $cache->delete('test1'); |
||
37 | $cache->delete('test2'); |
||
38 | |||
39 | $cache->fetch('test1'); |
||
40 | $cache->fetch('test2'); |
||
41 | $cache->fetch('test3'); |
||
42 | |||
43 | $stats = $cache->getStats(); |
||
44 | $this->assertEquals(2, $stats[Cache::STATS_HITS]); |
||
45 | $this->assertEquals(8, $stats[Cache::STATS_MISSES]); // +1 for internal call to DoctrineNamespaceCacheKey |
||
46 | } |
||
47 | |||
48 | protected function isSharedStorage() |
||
49 | { |
||
50 | return false; |
||
51 | } |
||
52 | } |