コード例 #1
0
 /**
  * @group disconnected
  */
 public function testCanSetReadOnlyFlagForEvalScripts()
 {
     $profile = ServerProfile::get('dev');
     $cmdEval = $profile->createCommand('eval', array($script = "return redis.call('info');"));
     $cmdEvalSha = $profile->createCommand('evalsha', array($scriptSHA1 = sha1($script)));
     $master = $this->getMockConnection('tcp://host1?alias=master');
     $master->expects($this->never())->method('executeCommand');
     $slave1 = $this->getMockConnection('tcp://host2?alias=slave1');
     $slave1->expects($this->exactly(2))->method('executeCommand')->with($this->logicalOr($cmdEval, $cmdEvalSha));
     $replication = new MasterSlaveReplication();
     $replication->add($master);
     $replication->add($slave1);
     $replication->setScriptReadOnly($script);
     $replication->executeCommand($cmdEval);
     $replication->executeCommand($cmdEvalSha);
 }