/** * Testing Script run against DB * Sessions and transactions are linked ATM * * @return void */ public function testRunScriptSession() { $db = new Connection(); $message = $db->open('localhost:8182', 'graph', $this->username, $this->password); $this->assertNotEquals($message, FALSE, 'Failed to connect to db'); $result = $db->send('5+5', 'session', 'eval'); $this->assertEquals($result[0], 10, 'Script response message is not the right type. (Maybe it\'s an error)'); //check it's a session script reply $result = $db->send('g.V()', 'session', 'eval'); $this->assertEquals(count($result), 6, 'Script response message is not the right type. (Maybe it\'s an error)'); //check it's a session script reply //check disconnection $db->close(); $this->assertFALSE($db->isConnected(), 'Despite not throwing errors, Socket connection is not established'); $this->assertFALSE($db->inTransaction(), 'Despite closing, transaction not closed'); }
/** * Testing Script run against DB * * @return void */ public function testRunScript() { $db = new Connection(); $message = $db->open('localhost:8184', 'tinkergraph', $this->username, $this->password); $db->script = '5+5'; $result = $db->runScript(); $this->assertNotEquals($result, FALSE, 'Script request throws an error'); $this->assertTRUE($db->response[2] == 5, 'Script response message is not the right type. (Maybe it\'s an error)'); //check it's a session script reply $db->script = 'g.v(2)'; $result = $db->runScript(); $this->assertNotEquals($result, FALSE, 'Script request throws an error'); $this->assertTRUE($db->response[2] == 5, 'Script response message is not the right type. (Maybe it\'s an error)'); //check it's a session script reply //check disconnection $message = $db->close(); $this->assertNotEquals($message, FALSE, 'Closing connection on script creates an Error'); $this->assertFALSE($db->isConnected(), 'Despite not throwing errors, Socket connection is not established'); $this->assertTRUE($db->response[2] == 2, 'Response packet for closing session is not the proper type. (Maybe it\'s an error)'); //check it's a session stop server packet }