getMockBuilder('Predis\Connection\NodeConnectionInterface')->getMock(); $connection ->expects($this->exactly(3)) ->method('writeRequest'); $connection ->expects($this->never()) ->method('readResponse'); $pipeline = new FireAndForget(new Client($connection)); $pipeline->ping(); $pipeline->ping(); $pipeline->ping(); $this->assertEmpty($pipeline->execute()); } /** * @group disconnected */ public function testSwitchesToMasterWithReplicationConnection(): void { $connection = $this->getMockBuilder('Predis\Connection\Replication\ReplicationInterface') ->getMock(); $connection ->expects($this->once()) ->method('switchToMaster'); $connection ->expects($this->exactly(3)) ->method('writeRequest'); $connection ->expects($this->never()) ->method('readResponse'); $pipeline = new FireAndForget(new Client($connection)); $pipeline->ping(); $pipeline->ping(); $pipeline->ping(); $this->assertEmpty($pipeline->execute()); } }