getLength()); self::assertEquals([], $path->getPath()); self::assertEquals([], $path->expandPath()); } #[\PHPUnit\Framework\Attributes\Group('framework')] #[\PHPUnit\Framework\Attributes\TestDox('The diagonal euclidean path length is calculated correctly')] public function testDiagonalPathLength() : void { $grid = Grid::createGridFromArray([ [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], ], Node::class); $path = new Path($grid); $path->addNode(new Node(1, 3)); $path->addNode(new Node(3, 1)); $path->addNode(new Node(4, 0)); self::assertEqualsWithDelta(4.2426, $path->getLength(), 0.001); } #[\PHPUnit\Framework\Attributes\Group('framework')] #[\PHPUnit\Framework\Attributes\TestDox('The straight euclidean path length is calculated correctly')] public function testStraightPathLength() : void { $grid = Grid::createGridFromArray([ [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], ], Node::class); $path = new Path($grid); $path->addNode(new Node(1, 3)); $path->addNode(new Node(1, 1)); $path->addNode(new Node(3, 1)); self::assertEqualsWithDelta(4.0, $path->getLength(), 0.001); } #[\PHPUnit\Framework\Attributes\Group('framework')] #[\PHPUnit\Framework\Attributes\TestDox('The path is correctly expanded in case only jump points are defined')] public function testPathExpansion() : void { $grid = Grid::createGridFromArray([ [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], ], Node::class); $path = new Path($grid); $path->addNode(new Node(1, 3)); $path->addNode(new Node(3, 1)); $path->addNode(new Node(4, 0)); self::assertEquals(3, \count($path->getPath())); self::assertEquals(4, \count($path->expandPath())); } }