/** * Set up test case * @return void */ public function setUp() { $phpredisVersion = phpversion('redis'); if (version_compare($phpredisVersion, '1.2.0', '<')) { $this->markTestSkipped(sprintf('phpredis extension version %s is not supported. Please update to verson 1.2.0+.', $phpredisVersion)); } $this->redis = $this->getMockBuilder(\Redis::class)->disableOriginalConstructor()->getMock(); $this->cache = $this->createMock(FrontendInterface::class); $this->cache->expects($this->any())->method('getIdentifier')->will($this->returnValue('Foo_Cache')); $mockEnvironmentConfiguration = $this->getMockBuilder(EnvironmentConfiguration::class)->setConstructorArgs([__DIR__ . '~Testing', 'vfs://Foo/', 255])->getMock(); $this->backend = new RedisBackend($mockEnvironmentConfiguration, ['redis' => $this->redis]); $this->backend->setCache($this->cache); }
/** * Set up test case * * @return void */ public function setUp() { $phpredisVersion = phpversion('redis'); if (version_compare($phpredisVersion, '1.2.0', '<')) { $this->markTestSkipped(sprintf('phpredis extension version %s is not supported. Please update to verson 1.2.0+.', $phpredisVersion)); } try { if (!@fsockopen('127.0.0.1', 6379)) { $this->markTestSkipped('redis server not reachable'); } } catch (\Exception $e) { $this->markTestSkipped('redis server not reachable'); } $this->backend = new RedisBackend(new EnvironmentConfiguration('Redis a wonderful color Testing', '/some/path', PHP_MAXPATHLEN), ['hostname' => '127.0.0.1', 'database' => 0]); $this->cache = $this->createMock(FrontendInterface::class); $this->cache->expects($this->any())->method('getIdentifier')->will($this->returnValue('TestCache')); $this->backend->setCache($this->cache); $this->backend->flush(); }