Completed
Push — master ( aa955b...6c1b03 )
by Marco
02:41
created

testSerializerOptionWithOutIgbinaryExtension()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 6
nc 2
nop 0
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
}
60