public function testRepeatedFailover() { $clientA = new PhpIRedisClient('someCircleA', 'localhost', 6379); $clientB = new PhpIRedisClient('someCircleB', 'unreachableHost', 6379); $clientC = new PhpIRedisClient('someCircleC', 'localhost', 6379); $redis = new FailoverWrapper(array($clientA, $clientB, $clientC)); $this->assertTrue($redis->connect(null)); $redis->del('testDeadConn'); $this->assertEquals(1, $redis->incr('testDeadConn')); // now we leverage a ton of knowledge about the setup, but since we are in a unit test // and control everything, its fine // interupt the connection phpiredis_command_bs($this->readAttribute($clientA, 'connection'), array('QUIT')); $clientA->prepareConnect('unreachableHost'); // everything should still work at this place, because there is a backup connection $this->assertEquals(1, $redis->get('testDeadConn')); $this->assertFalse($clientA->isconnected()); $this->assertFalse($clientB->isconnected()); $this->assertTrue($clientC->isconnected()); }