/**
  * @group disconnected
  */
 public function testGetDevelopment()
 {
     $profile1 = ServerProfile::get('dev');
     $profile2 = ServerProfile::getDevelopment();
     $this->assertInstanceOf('Predis\\Profile\\ServerProfileInterface', $profile1);
     $this->assertInstanceOf('Predis\\Profile\\ServerProfileInterface', $profile2);
     $this->assertEquals(self::DEVELOPMENT_PROFILE_VERSION, $profile2->getVersion());
 }
 /**
  * Returns a list of queued command instances.
  *
  * @return SplQueue
  */
 protected function getCommandsQueue()
 {
     $profile = ServerProfile::getDevelopment();
     $pipeline = new SplQueue();
     $pipeline->enqueue($profile->createCommand('ping'));
     $pipeline->enqueue($profile->createCommand('ping'));
     $pipeline->enqueue($profile->createCommand('ping'));
     return $pipeline;
 }
Esempio n. 3
0
 /**
  * @group disconnected
  */
 public function testSetLuaScriptAsReadOperation()
 {
     $strategy = new ReplicationStrategy();
     $profile = ServerProfile::getDevelopment();
     $writeScript = 'redis.call("set", "foo", "bar")';
     $readScript = 'return true';
     $strategy->setScriptReadOnly($readScript, true);
     $cmdEval = $profile->createCommand('EVAL', array($writeScript));
     $cmdEvalSHA = $profile->createCommand('EVALSHA', array(sha1($writeScript)));
     $this->assertFalse($strategy->isReadOperation($cmdEval));
     $this->assertFalse($strategy->isReadOperation($cmdEvalSHA));
     $cmdEval = $profile->createCommand('EVAL', array($readScript));
     $cmdEvalSHA = $profile->createCommand('EVALSHA', array(sha1($readScript)));
     $this->assertTrue($strategy->isReadOperation($cmdEval));
     $this->assertTrue($strategy->isReadOperation($cmdEvalSHA));
 }
 /**
  * @group disconnected
  */
 public function testSettingCustomCommandHandler()
 {
     $strategy = $this->getHashStrategy();
     $profile = ServerProfile::getDevelopment();
     $callable = $this->getMock('stdClass', array('__invoke'));
     $callable->expects($this->once())->method('__invoke')->with($this->isInstanceOf('Predis\\Command\\CommandInterface'))->will($this->returnValue('key'));
     $strategy->setCommandHandler('get', $callable);
     $command = $profile->createCommand('get', array('key'));
     $this->assertNotNull($strategy->getHash($command));
 }