/** * Testing transactions accross multiple script launches * * @return void */ public function testTransactionsMultiRun() { $db = new Connection(); $message = $db->open('localhost:8182', 'graphT', $this->username, $this->password); $this->assertNotEquals($message, FALSE); $result = $db->send('t.V().count()'); $elementCount = $result[0]; $db->transactionStart(); $db->send('t.addV("name","michael").next()'); $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'); $db->transactionStart(); $db->send('t.addV("name","michael").next()'); $db->send('t.addV("name","michael").next()'); $db->transactionStop(TRUE); $db->message->gremlin = 't.V().count()'; $result = $db->send(); $elementCount2 = $result[0]; $this->AssertEquals($elementCount + 2, $elementCount2, 'Transaction submition didn\'t work'); }
/** * Testing getSerializer * * @expectedException \brightzone\rexpro\ServerException * * @return void */ public function testEmptyResult() { $db = new Connection(); $message = $db->open('localhost:8182', 'graph', $this->username, $this->password); $this->assertNotEquals($message, FALSE, 'Failed to connect to db'); $db->send('g.V().has("idontexists")'); }
/** * Testing Example 5 * * @return void */ public function testExample5() { $message = new Messages(); $message->gremlin = 'g.V()'; $message->op = 'eval'; $message->processor = ''; $message->setArguments(['language' => 'gremlin-groovy']); $message->registerSerializer('\\brightzone\\rexpro\\serializers\\Json'); $db = new Connection(); $db->open(); $result = $db->send($message); //do something with result $db->close(); }
/** * Testing sendMessage without previous connection * * @return void */ public function testSendMessageWithoutConnection() { $db = new Connection(); $msg = new Messages(0); $result = $db->send($msg); $this->assertFalse($result, 'Failed to return false with no established connection'); }
/** * Testing sendMessage without previous connection * * @return void */ public function testSendMessageWithoutConnection() { $db = new Connection(); $db->setSerializer(Messages::SERIALIZER_JSON); $msg = new Messages(1); $result = $db->send($msg); $this->assertFalse($result, 'Failed to return false with no established connection'); }