示例#1
0
 public function testAuthenticationComplex()
 {
     $db = new Connection(['host' => 'localhost', 'port' => 8184, 'graph' => 'graph', 'username' => 'stephen', 'password' => 'password', 'ssl' => ["ssl" => ["verify_peer" => false, "verify_peer_name" => false]]]);
     $message = $db->open();
     $result = $db->send('g.V().emit().repeat(__.both()).times(5)');
     $this->assertEquals(count($result), 714, 'Did not find the correct amounts of vertices');
     //check it's a session script reply
 }
 /**
  * @param array $options
  *
  * @throws \Exception
  *
  * @return bool
  */
 public static function getConnection($options = [])
 {
     static $connection = null;
     if ($connection === null) {
         $configConnection = ['host' => env('GREMLIN_HOST', isset($options['host']) ? $options['host'] : 'localhost'), 'port' => env('GREMLIN_PORT', isset($options['port']) ? $options['port'] : '8182'), 'graph' => env('GREMLIN_GRAPH', isset($options['graph']) ? $options['graph'] : 'graph'), 'username' => env('GREMLIN_USERNAME', isset($options['username']) ? $options['username'] : null), 'password' => env('GREMLIN_PASSWORD', isset($options['password']) ? $options['password'] : null), 'ssl' => env('GREMLIN_SSL', isset($options['ssl']) ? $options['ssl'] : null)];
         $connection = new GremlinConnection($configConnection);
         $connection->open();
     }
     return $connection;
 }
 /**
  * Testing combination of session and sessionless requests
  */
 public function testSessionSessionlessCombinationConcurrentRollback()
 {
     $db = new Connection(['graph' => 'graphT', 'username' => $this->username, 'password' => $this->password]);
     $message = $db->open();
     $this->assertNotEquals($message, FALSE);
     $db2 = new Connection(['graph' => 'graphT', 'username' => $this->username, 'password' => $this->password]);
     $message = $db2->open();
     $this->assertNotEquals($message, FALSE);
     $result = $db->send('t.V().count()');
     $elementCount = $result[0];
     $db->transactionStart();
     $db->send('t.addV("name","michael").next()');
     $db2->message->gremlin = 't.V()';
     $db2->send();
     $db->send('t.addV("name","michael").next()');
     $db->transactionStop(FALSE);
     $db->message->gremlin = 't.V().count()';
     $result = $db->send();
     $elementCount2 = $result[0];
     $this->AssertEquals($elementCount, $elementCount2, 'Transaction rollback didn\'t work');
 }
 /**
  * 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();
 }
 /**
  * Lets test retrning a large set back from the database
  *
  * @return void
  */
 public function testLargeResponseSet()
 {
     $db = new Connection(['host' => 'localhost', 'port' => 8182, 'graph' => 'graph', 'retryAttempts' => 5]);
     $db->open();
     $db->send("\n            for(i in 1..35){\n                graph.addVertex('name', 'john', 'age', 25, 'somefillertext', 'FFFFFFFFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFF')\n            }");
     $result = $db->send("g.V()");
     $db->close();
 }