/** * Test unmasking of packet * * @return void */ public function testPackUnpack() { $message = new Message(); //$message->status = ["code" => 200]; $message->gremlin = "something"; $message->registerSerializer('\\Brightzone\\GremlinDriver\\Serializers\\Json'); $payload = $message->buildMessage(); $expected = ['requestId' => $message->requestUuid, 'processor' => '', 'op' => 'eval', 'args' => ['gremlin' => 'something']]; $connection = new \Brightzone\GremlinDriver\Tests\Stubs\Connection(["_acceptDiffResponseFormat" => TRUE]); $connection->setSocket($this->invokeMethod($connection, 'webSocketPack', [$payload, $type = 'binary', $masked = TRUE])); $data = $this->invokeMethod($connection, 'socketGetMessage'); $this->assertEquals($expected, $data, "could not unpack properly"); }
/** * Testing Example 5 * * @return void */ public function testExample5() { $message = new Message(); $message->gremlin = 'g.V()'; $message->op = 'eval'; $message->processor = ''; $message->setArguments(['language' => 'gremlin-groovy']); $message->registerSerializer('\\Brightzone\\GremlinDriver\\Serializers\\Json'); $db = new Connection(); $db->open(); $db->send($message); //do something with result $db->close(); }
/** * Builds an authentication message when challenged by the server * * @return void */ protected function authenticate() { $msg = new Message(); $msg->op = "authentication"; $msg->processor = ""; $msg->setArguments(['sasl' => base64_encode(utf8_encode("" . trim($this->username) . "" . trim($this->password)))]); $msg->registerSerializer(new Json()); return $this->send($msg); }