/**
  * test for replacing a edge using replace()
  */
 public function testReplaceEdge()
 {
     $connection = $this->connection;
     $edgeHandler = new EdgeHandler($connection);
     $edgeCollection = $this->edgeCollection;
     $document1 = new Document();
     $document2 = new Document();
     $documentHandler = new DocumentHandler($connection);
     $edgeDocument = new Edge();
     $document1->someAttribute = 'someValue1';
     $document2->someAttribute = 'someValue2';
     $documentHandler->add('ArangoDBPHPTestSuiteTestCollection01', $document1);
     $documentHandler->add('ArangoDBPHPTestSuiteTestCollection01', $document2);
     $documentHandle1 = $document1->getHandle();
     $documentHandle2 = $document2->getHandle();
     $edgeDocument->set('label', null);
     $edgeDocument->set('labelt', "as");
     $edgeId = $edgeHandler->saveEdge($edgeCollection->getName(), $documentHandle1, $documentHandle2, $edgeDocument);
     $this->assertTrue(is_numeric($edgeId), 'Did not return an id!');
     $edgePutDocument = new Edge();
     $edgePutDocument->set('_id', $edgeDocument->getHandle());
     $edgePutDocument->set('_rev', $edgeDocument->getRevision());
     $edgePutDocument->set('labels', "as");
     $result = $edgeHandler->replace($edgePutDocument);
     $this->assertTrue($result);
     $resultingEdge = $edgeHandler->get($edgeCollection->getId(), $edgeId);
     $this->assertObjectHasAttribute('_id', $resultingEdge, '_id field should exist, empty or with an id');
     $this->assertTrue($resultingEdge->label == null, 'Should be :null, is: ' . $resultingEdge->label);
     $this->assertTrue($resultingEdge->labelt == null, 'Should be :null, is: ' . $resultingEdge->labelt);
     $this->assertTrue($resultingEdge->labels == "as");
     $response = $edgeHandler->delete($resultingEdge);
     $this->assertTrue($response, 'Delete should return true!');
 }
 /**
  * Try to create, get and delete a edge using the revision-
  */
 public function testCreateGetAndDeleteEdgeWithRevision()
 {
     $connection = $this->connection;
     $edgeHandler = new EdgeHandler($connection);
     $edgeCollection = $this->edgeCollection;
     $document1 = new Document();
     $document2 = new Document();
     $documentHandler = new DocumentHandler($connection);
     $edgeDocument = new Edge();
     $document1->someAttribute = 'someValue1';
     $document2->someAttribute = 'someValue2';
     $documentHandler->add('ArangoDBPHPTestSuiteTestCollection01', $document1);
     $documentHandler->add('ArangoDBPHPTestSuiteTestCollection01', $document2);
     $documentHandle1 = $document1->getHandle();
     $documentHandle2 = $document2->getHandle();
     $edgeDocument->set('label', 'knows');
     $edgeId = $edgeHandler->saveEdge($edgeCollection->getName(), $documentHandle1, $documentHandle2, $edgeDocument);
     /**
      * lets get the edge in a wrong revision
      */
     try {
         $edgeHandler->get($edgeCollection->getId(), $edgeId, array("ifMatch" => true, "revision" => 12345));
     } catch (\Exception $exception412) {
     }
     $this->assertEquals($exception412->getCode(), 412);
     try {
         $edgeHandler->get($edgeCollection->getId(), $edgeId, array("ifMatch" => false, "revision" => $edgeDocument->getRevision()));
     } catch (\Exception $exception304) {
     }
     $this->assertEquals($exception304->getMessage(), 'Document has not changed.');
     $resultingEdge = $edgeHandler->get($edgeCollection->getId(), $edgeId);
     $resultingEdge->set('someAttribute', 'someValue2');
     $resultingEdge->set('someOtherAttribute', 'someOtherValue2');
     $edgeHandler->replace($resultingEdge);
     $oldRevision = $edgeHandler->get($edgeCollection->getId(), $edgeId, array("revision" => $resultingEdge->getRevision()));
     $this->assertEquals($oldRevision->getRevision(), $resultingEdge->getRevision());
     $documentHandler->delete($document1);
     $documentHandler->delete($document2);
     $edgeHandler->deleteById($edgeCollection->getName(), $edgeId);
 }