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

RedisCacheTest::_getCacheDriver()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 6
rs 9.4286
cc 1
eloc 4
nc 1
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
    /**
39
     * {@inheritDoc}
40
     */
41
    protected function _getCacheDriver()
42
    {
43
        $driver = new RedisCache();
44
        $driver->setRedis($this->_redis);
45
        return $driver;
46
    }
47
}
48