/** * 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 4 * * @return void */ public function testExample4() { $db = new Connection(['host' => 'localhost', 'port' => 8182, 'graph' => 'graphT']); $db->open(); $originalCount = $db->send('n.V().count()'); $db->transactionStart(); $db->send('n.addVertex("name","michael")'); $db->send('n.addVertex("name","john")'); $db->transactionStop(FALSE); //rollback changes. Set to true to commit. $newCount = $db->send('n.V().count()'); $this->assertEquals($newCount, $originalCount, 'Rollback was not done for eample 4'); $db->close(); }