public function setUp()
 {
     $this->connection = getConnection();
     $v = time();
     $this->graphName = "graph" . $v;
     $this->v1 = "v1" . $v;
     $this->v2 = "v2" . $v;
     $this->v3 = "v3" . $v;
     $this->v4 = "v4" . $v;
     $this->v5 = "v5" . $v;
     $this->e1 = "e1" . $v;
     $this->e2 = "e2" . $v;
     $param1 = array();
     $param1[] = $this->v1;
     $param1[] = $this->v2;
     $param2 = array();
     $param2[] = $this->v3;
     $param2[] = $this->v4;
     $ed1 = EdgeDefinition::createDirectedRelation($this->e1, $param1, $param2);
     $ed2 = EdgeDefinition::createUndirectedRelation($this->e2, $this->v5);
     $this->graph = new Graph($this->graphName);
     $this->graph->addEdgeDefinition($ed1);
     $this->graph->addEdgeDefinition($ed2);
     $this->graph->addOrphanCollection("orphan");
     $this->graphHandler = new GraphHandler($this->connection);
     $this->graphHandler->createGraph($this->graph);
     $this->graph = $this->graphHandler->getGraph($this->graphName);
     $this->vertex1Array = array('_key' => "vertex1", 'someKey1' => 'someValue1', 'sharedKey1' => 1);
     $this->vertex2Array = array('_key' => "vertex2", 'someKey2' => 'someValue2', 'sharedKey1' => 2);
     $this->vertex3Array = array('_key' => "vertex3", 'someKey3' => 'someValue3', 'sharedKey1' => 1);
     $this->vertex4Array = array('_key' => "vertex4", 'someKey4' => 'someValue4', 'sharedKey1' => 2);
     $this->vertex5Array = array('_key' => "vertex5", 'someKey5' => 'someValue5', 'a' => 3, 'sharedKey1' => 1);
     $this->vertex6Array = array('_key' => "vertex6", 'someKey6' => 'someValue6', 'sharedKey1' => 1);
     $this->vertex7Array = array('_key' => "vertex7", 'someKey7' => 'someValue7', 'a' => 3, 'sharedKey1' => 1);
     $this->edge1Array = array('_key' => "edge1", 'someEdgeKey1' => 'someEdgeValue1', 'sharedKey1' => 1, 'weight' => 10);
     $this->edge2Array = array('_key' => "edge2", 'someEdgeKey2' => 'someEdgeValue2', 'sharedKey2' => 2, 'weight' => 15);
     $this->edge3Array = array('_key' => "edge3", 'sharedKey3' => 2, 'weight' => 12);
     $this->edge4Array = array('_key' => "edge4", 'sharedKey4' => 1, 'weight' => 7);
     $this->edge5Array = array('_key' => "edge5", 'sharedKey5' => 1, 'weight' => 5);
     $this->edge6Array = array('_key' => "edge6", 'sharedKey6' => 1, 'weight' => 2);
 }
 /**
  * Test adding, getting and deleting of edgecollections
  */
 public function testAddGetDeleteEdgeCollections()
 {
     $this->graph = new Graph('Graph1');
     $ed1 = EdgeDefinition::createUndirectedRelation("undirected", "singleV");
     $this->graph->addEdgeDefinition($ed1);
     $this->graphHandler = new GraphHandler($this->connection);
     $result = $this->graphHandler->createGraph($this->graph);
     $this->assertTrue($result['_key'] == 'Graph1', 'Did not return Graph1!');
     $this->graph = $this->graphHandler->addEdgeDefinition($this->graph, EdgeDefinition::createUndirectedRelation("undirected2", "singleV2"));
     $this->assertTrue($this->graphHandler->getEdgeCollections($this->graph) === array(0 => 'undirected', 1 => 'undirected2'));
     $error = null;
     try {
         $this->graph = $this->graphHandler->addEdgeDefinition($this->graph, EdgeDefinition::createUndirectedRelation("undirected2", "singleV2"));
     } catch (\Exception $e) {
         $error = $e->getMessage();
     }
     $this->assertTrue($error === "multi use of edge collection in edge def");
     $error = null;
     try {
         $this->graph = $this->graphHandler->getEdgeCollections("bla");
     } catch (\Exception $e) {
         $error = $e->getMessage();
     }
     $this->assertTrue($error === "graph not found");
     $this->graph = $this->graphHandler->deleteEdgeDefinition($this->graph, "undirected");
     $this->assertTrue($this->graphHandler->getEdgeCollections($this->graph) === array(0 => 'undirected2'));
     $error = null;
     try {
         $this->graph = $this->graphHandler->deleteEdgeDefinition("bla", "undefined");
     } catch (\Exception $e) {
         $error = $e->getMessage();
     }
     $this->assertTrue($error === "graph not found");
     $this->graph = $this->graphHandler->replaceEdgeDefinition($this->graph, EdgeDefinition::createUndirectedRelation("undirected2", "singleV3"));
     $ed = $this->graph->getEdgeDefinitions();
     $ed = $ed[0];
     $ed = $ed->getToCollections();
     $this->assertTrue($ed[0] === "singleV3");
     $error = null;
     try {
         $this->graph = $this->graphHandler->replaceEdgeDefinition($this->graph, EdgeDefinition::createUndirectedRelation("notExisting", "singleV3"));
     } catch (\Exception $e) {
         $error = $e->getMessage();
     }
     $this->assertTrue($error === "edge collection not used in graph");
 }