예제 #1
0
 public function testSendMessage()
 {
     $message = new RpbPutReq();
     $reqCode = RiakMessageCodes::PUT_REQ;
     $respCode = RiakMessageCodes::PUT_RESP;
     $respBody = Protobuf::encode(new RpbPutResp());
     $stream = $this->getMock('Riak\\Client\\Core\\Transport\\Proto\\ProtoStream', [], [], '', false);
     $this->connection->expects($this->once())->method('send')->willReturn($stream);
     $this->connection->expects($this->once())->method('receive')->willReturn([$respCode, $respBody])->with($this->equalTo($stream));
     $this->assertInstanceOf('Riak\\Client\\ProtoBuf\\RpbPutResp', $this->instance->send($message, $reqCode, $respCode));
 }
예제 #2
0
 /**
  * @runInSeparateProcess
  * @expectedException Riak\Client\Core\Transport\RiakTransportException
  * @expectedExceptionMessage Fail to connect to : tcp://riak.local:8087 [ ]
  */
 public function testCreateConnectionException()
 {
     $mocks = $this->createMockFunctions();
     $mocks['stream_socket_client']->expects($this->once())->with($this->equalTo('tcp://riak.local:8087'))->willReturn(null);
     $mocks['is_resource']->expects($this->once())->willReturn(false);
     $this->instance->createStream();
 }
예제 #3
0
 /**
  * @param \DrSlump\Protobuf\Message $message
  * @param integer                   $code
  *
  * @return string
  */
 private function encodeMessage(Message $message, $code)
 {
     return $this->connection->encode(Protobuf::encode($message), $code);
 }