Completed
Push — master ( a8b991...dda2b8 )
by Marco
06:05 queued 02:56
created

RedisCacheTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 37
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 8 2
A testHitMissesStatsAreProvided() 0 8 1
A testGetRedisReturnsInstanceOfRedis() 0 4 1
A _getCacheDriver() 0 6 1
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
    /**
39
     * {@inheritDoc}
40
     */
41
    protected function _getCacheDriver()
42
    {
43
        $driver = new RedisCache();
44
        $driver->setRedis($this->_redis);
45
        return $driver;
46
    }
47
}
48