/**
  * Test for creation of a graph and a traversal
  * Modeled after: http://www.arangodb.com/manuals/1.4/HttpTraversals.html
  *
  * Test:
  * If the underlying graph is cyclic, maxIterations should be set:
  * The underlying graph has two vertices Alice and Bob. With the directed edges:
  * Alice knows Bob _ Bob knows Alice
  */
 public function testTraversalTooManyIterations()
 {
     $this->createGraph();
     $startVertex = $this->vertexCollectionName . '/' . $this->vertex1Name;
     $edgeCollection = $this->edgeCollectionName;
     $options = array('direction' => 'any', 'uniqueness' => array('vertices' => 'none', 'edges' => 'none'), 'maxIterations' => 5);
     $traversal = new Traversal($this->connection, $startVertex, $edgeCollection, $options);
     try {
         $traversal->getResult();
     } catch (Exception $e) {
         // don't bother us, if it's already deleted.
     }
     $details = $e->getDetails();
     $expectedCutDownMessage = "too many iterations";
     $len = strlen($expectedCutDownMessage);
     $this->assertTrue($e->getCode() == 500 && substr($details['errorMessage'], 0, $len) == $expectedCutDownMessage, 'Did not return code 500 with first part of the message: "' . $expectedCutDownMessage . '", instead returned: ' . $e->getCode() . ' and "' . $details['errorMessage'] . '"');
 }
 public function testPagedTraversal_ServerReturnsError_ThrowsException()
 {
     $traversal = new Traversal($this->client);
     $traversal->setOrder(Traversal::OrderDepthFirst);
     $node = new Node($this->client);
     $node->setId(1);
     $pager = new Pager($traversal, $node, Traversal::ReturnTypeNode);
     $pager->setPageSize(1)->setLeaseTime(30);
     $this->transport->expects($this->once())->method('post')->with('/node/1/paged/traverse/node?pageSize=1&leaseTime=30', array("order" => "depth_first"))->will($this->returnValue(array("code" => 400)));
     $this->setExpectedException('Everyman\\Neo4j\\Exception');
     $result = $this->client->executePagedTraversal($pager);
 }