public function testEncode()
 {
     $message = RPCMessage::createWithRpc('a.a', ['b' => 123], 2);
     $encodeMessage = $message->encode();
     self::assertNotEmpty($encodeMessage);
     $decodeMessages = RPCMessage::decode($encodeMessage);
     self::assertNotEmpty($decodeMessages);
     self::assertEquals(count($decodeMessages), 1);
     /**
      * @var $decodeMessage RPCMessage
      */
     $decodeMessage = end($decodeMessages);
     self::assertTrue($decodeMessage instanceof RPCMessage);
     self::assertEquals('a.a', $decodeMessage->getFunctionName());
     self::assertEquals(['b' => 123], $decodeMessage->getFunctionParams());
 }
 public function testEncodeOrDecode()
 {
     $messages = [];
     $messages[] = RPCMessage::createWithRpc('a.a', ['b' => 1]);
     $messages[] = RPCMessage::createWithRpc('b.b', ['c' => 1]);
     $messageString = RPCMessageEncode::encodeMessages($messages);
     $this->assertNotEmpty($messageString);
     $decodeMessages = RPCMessageEncode::decodeMessages($messageString);
     $this->assertTrue(is_array($decodeMessages));
     $this->assertCount(2, $decodeMessages);
     foreach ($decodeMessages as $decodeMessage) {
         $this->assertInstanceOf(RPCMessage::class, $decodeMessage);
     }
     $decodeMessage = $decodeMessages[0];
     if ($decodeMessage instanceof RPCMessage) {
         $this->assertEquals('a.a', $decodeMessage->getMessageBodyProperty(RPCMessage::Msg_RPC_FunctionName));
         $this->assertEquals(['b' => 1], $decodeMessage->getMessageBodyProperty(RPCMessage::Msg_PPC_FunctionParams));
     }
     $decodeMessage = $decodeMessages[1];
     if ($decodeMessage instanceof RPCMessage) {
         $this->assertEquals('b.b', $decodeMessage->getMessageBodyProperty(RPCMessage::Msg_RPC_FunctionName));
         $this->assertEquals(['c' => 1], $decodeMessage->getMessageBodyProperty(RPCMessage::Msg_PPC_FunctionParams));
     }
 }