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));
 }
Beispiel #2
0
 function testMultiCodecMessageWithRepeatedFields()
 {
     $jsonCodec = new Codec\Json();
     $repeated = Protobuf\Protobuf::decode(Repeated::class, $this->bin_repeated_nested);
     $json = $jsonCodec->encode($repeated);
     $repeated = $jsonCodec->decode(new Repeated(), $json);
     $bin = Protobuf\Protobuf::encode($repeated);
     $this->assertEquals($bin, $this->bin_repeated_nested);
 }
Beispiel #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);
 }