Ejemplo n.º 1
0
 /**
  * @param MyNode $needle
  * @param MyNode[] $haystack
  */
 private function assertContainsMyNode(MyNode $needle, array $haystack)
 {
     foreach ($haystack as $node) {
         if ($needle->getID() === $node->getID()) {
             return;
         }
     }
     $this->fail('Failed asserting that the array ' . print_r($haystack, true) . 'contains the specified node ' . print_r($needle, true));
 }
Ejemplo n.º 2
0
 /**
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage Invalid node
  */
 public function testShouldNotCreateNewInstanceFromInvalidNode()
 {
     $nodeID = 'foo';
     $node = $this->getMock('JMGQ\\AStar\\Node');
     $node->expects($this->once())->method('getID')->will($this->returnValue($nodeID));
     MyNode::fromNode($node);
 }
Ejemplo n.º 3
0
 private function areAdjacent(MyNode $a, MyNode $b)
 {
     return abs($a->getRow() - $b->getRow()) <= 1 && abs($a->getColumn() - $b->getColumn()) <= 1;
 }