RedisCacheTest.php 1022 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace Doctrine\Tests\Common\Cache;
  3. use Doctrine\Common\Cache\RedisCache;
  4. use Doctrine\Common\Cache\Cache;
  5. class RedisCacheTest extends CacheTest
  6. {
  7. private $_redis;
  8. public function setUp()
  9. {
  10. if (extension_loaded('redis')) {
  11. $this->_redis = new \Redis();
  12. $ok = @$this->_redis->connect('127.0.0.1');
  13. if (!$ok) {
  14. $this->markTestSkipped('The ' . __CLASS__ .' requires the use of redis');
  15. }
  16. } else {
  17. $this->markTestSkipped('The ' . __CLASS__ .' requires the use of redis');
  18. }
  19. }
  20. public function testHitMissesStatsAreProvided()
  21. {
  22. $cache = $this->_getCacheDriver();
  23. $stats = $cache->getStats();
  24. $this->assertNotNull($stats[Cache::STATS_HITS]);
  25. $this->assertNotNull($stats[Cache::STATS_MISSES]);
  26. }
  27. protected function _getCacheDriver()
  28. {
  29. $driver = new RedisCache();
  30. $driver->setRedis($this->_redis);
  31. return $driver;
  32. }
  33. }