Exemple #1
0
 /**
  * Find paths from this node to the given node
  *
  * @param Node $to
  * @param string $type
  * @param string $dir
  * @return PathFinder
  */
 public function findPathsTo(Node $to, $type = null, $dir = null)
 {
     $finder = new PathFinder($this->client);
     $finder->setStartNode($this);
     $finder->setEndNode($to);
     if ($dir) {
         $finder->setDirection($dir);
     }
     if ($type) {
         $finder->setType($type);
     }
     return $finder;
 }
 public function testGetPaths_DijkstraSearch_ReturnsResult()
 {
     $startNode = new Node($this->client);
     $startNode->setId(123);
     $endNode = new Node($this->client);
     $endNode->setId(456);
     $finder = new PathFinder($this->client);
     $finder->setStartNode($startNode)->setEndNode($endNode)->setAlgorithm(PathFinder::AlgoDijkstra)->setCostProperty('distance')->setDefaultCost(2);
     $data = array('to' => $this->endpoint . '/node/456', 'max_depth' => 1, 'max depth' => 1, 'algorithm' => 'dijkstra', 'cost_property' => 'distance', 'cost property' => 'distance', 'default_cost' => 2, 'default cost' => 2);
     $returnData = array();
     $this->transport->expects($this->once())->method('post')->with('/node/123/paths', $data)->will($this->returnValue(array('code' => 200, 'data' => $returnData)));
     $paths = $this->client->getPaths($finder);
     $this->assertEquals(0, count($paths));
 }