protected function setUp()
{
if ($this->sentinelConfig === NULL) {
$configFile = dirname(__FILE__) . '/sentinel_config.json';
if (!file_exists($configFile) || !($config = file_get_contents($configFile))) {
$this->markTestSkipped('Could not load ' . $configFile);
return;
}
$this->sentinelConfig = json_decode($config);
}
if ($this->redisConfig === NULL) {
$configFile = dirname(__FILE__) . '/redis_config.json';
if (!file_exists($configFile) || !($config = file_get_contents($configFile))) {
$this->markTestSkipped('Could not load ' . $configFile);
return;
}
$this->redisConfig = json_decode($config);
$arrayConfig = array();
foreach ($this->redisConfig as $config) {
$arrayConfig[] = (array) $config;
}
$this->redisConfig = $arrayConfig;
}
$sentinelClient = new Credis_Client($this->sentinelConfig->host, $this->sentinelConfig->port);
$this->sentinel = new Credis_Sentinel($sentinelClient);
if ($this->useStandalone) {
$this->sentinel->forceStandalone();
} else {
if (!extension_loaded('redis')) {
$this->fail('The Redis extension is not loaded.');
}
}
}