3 namespace Doctrine\Tests\Common\Cache;
5 use Doctrine\Common\Cache\Cache;
6 use Doctrine\Common\Cache\PredisCache;
8 use Predis\Connection\ConnectionException;
10 class PredisCacheTest extends CacheTest
14 protected function setUp()
16 if (!class_exists('Predis\Client')) {
17 $this->markTestSkipped('Predis\Client is missing. Make sure to "composer install" to have all dev dependencies.');
20 $this->client = new Client();
23 $this->client->connect();
24 } catch (ConnectionException $e) {
25 $this->markTestSkipped('Cannot connect to Redis because of: ' . $e);
29 public function testHitMissesStatsAreProvided()
31 $cache = $this->_getCacheDriver();
32 $stats = $cache->getStats();
34 $this->assertNotNull($stats[Cache::STATS_HITS]);
35 $this->assertNotNull($stats[Cache::STATS_MISSES]);
41 protected function _getCacheDriver()
43 return new PredisCache($this->client);
49 * @dataProvider provideDataToCache
51 public function testSetContainsFetchDelete($value)
53 if (array() === $value) {
54 $this->markTestIncomplete(
55 'Predis currently doesn\'t support saving empty array values. '
56 . 'See https://github.com/nrk/predis/issues/241'
60 parent::testSetContainsFetchDelete($value);
66 * @dataProvider provideDataToCache
68 public function testUpdateExistingEntry($value)
70 if (array() === $value) {
71 $this->markTestIncomplete(
72 'Predis currently doesn\'t support saving empty array values. '
73 . 'See https://github.com/nrk/predis/issues/241'
77 parent::testUpdateExistingEntry($value);
80 public function testAllowsGenericPredisClient()
82 /* @var $predisClient \Predis\ClientInterface */
83 $predisClient = $this->getMock('Predis\\ClientInterface');
85 $this->assertInstanceOf('Doctrine\\Common\\Cache\\PredisCache', new PredisCache($predisClient));