scratch – Blame information for rev 120
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
120 | office | 1 | <?php |
2 | |||
3 | namespace Doctrine\Tests\Common\Cache; |
||
4 | |||
5 | use Doctrine\Common\Cache\RedisCache; |
||
6 | use Doctrine\Common\Cache\Cache; |
||
7 | |||
8 | /** |
||
9 | * @requires extension redis |
||
10 | */ |
||
11 | class RedisCacheTest extends CacheTest |
||
12 | { |
||
13 | private $_redis; |
||
14 | |||
15 | protected function setUp() |
||
16 | { |
||
17 | $this->_redis = new \Redis(); |
||
18 | $ok = @$this->_redis->connect('127.0.0.1'); |
||
19 | if (!$ok) { |
||
20 | $this->markTestSkipped('Cannot connect to Redis.'); |
||
21 | } |
||
22 | } |
||
23 | |||
24 | public function testHitMissesStatsAreProvided() |
||
25 | { |
||
26 | $cache = $this->_getCacheDriver(); |
||
27 | $stats = $cache->getStats(); |
||
28 | |||
29 | $this->assertNotNull($stats[Cache::STATS_HITS]); |
||
30 | $this->assertNotNull($stats[Cache::STATS_MISSES]); |
||
31 | } |
||
32 | |||
33 | public function testGetRedisReturnsInstanceOfRedis() |
||
34 | { |
||
35 | $this->assertInstanceOf('Redis', $this->_getCacheDriver()->getRedis()); |
||
36 | } |
||
37 | |||
38 | public function testSerializerOptionWithOutIgbinaryExtension() |
||
39 | { |
||
40 | if (defined('Redis::SERIALIZER_IGBINARY') && extension_loaded('igbinary')) { |
||
41 | $this->markTestSkipped('Extension igbinary is loaded.'); |
||
42 | } |
||
43 | |||
44 | $this->assertEquals( |
||
45 | \Redis::SERIALIZER_PHP, |
||
46 | $this->_getCacheDriver()->getRedis()->getOption(\Redis::OPT_SERIALIZER) |
||
47 | ); |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * {@inheritDoc} |
||
52 | */ |
||
53 | protected function _getCacheDriver() |
||
54 | { |
||
55 | $driver = new RedisCache(); |
||
56 | $driver->setRedis($this->_redis); |
||
57 | return $driver; |
||
58 | } |
||
59 | } |