/** * Testing That the server closes the session * * @expectedException \Brightzone\GremlinDriver\ServerException * * @return void */ public function testSessionClose() { $db = new Connection(['host' => 'localhost', 'port' => 8182, 'graph' => 'graph', 'username' => $this->username, 'password' => $this->password]); $message = $db->open(); $this->assertNotEquals($message, FALSE, 'Failed to connect to db'); $result = $db->send('cal = 5+5', 'session', 'eval'); $sessionUid = $db->getSession(); $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('cal', '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 //check disconnection try { $db->close(); } catch (\Exception $e) { $this->fail("Close shouldn't throw an exception"); } $this->assertFALSE($db->isConnected(), 'Despite not throwing errors, Socket connection is established'); $this->assertFALSE($db->inTransaction(), 'Despite closing, transaction not closed'); $db2 = new Connection(['host' => 'localhost', 'port' => 8182, 'graph' => 'graph', 'username' => $this->username, 'password' => $this->password]); $message = $db2->open(); $this->assertNotEquals($message, FALSE, 'Failed to connect to db'); $msg = new Message(); $msg->registerSerializer('\\Brightzone\\GremlinDriver\\Serializers\\Json'); $msg->gremlin = 'cal'; $msg->op = 'eval'; $msg->processor = 'session'; $msg->setArguments(['session' => $sessionUid]); $result = $db2->send($msg); // should throw an error as this should be next session $this->fail("Second request should have failed and this assert never run"); }