|
|
@ -8,126 +8,126 @@ require __DIR__ . '/../../vendor/autoload.php'; |
|
|
|
class PositionTest extends \PHPUnit_Framework_TestCase { |
|
|
|
class PositionTest extends \PHPUnit_Framework_TestCase { |
|
|
|
|
|
|
|
|
|
|
|
public function testColumnIndex() { |
|
|
|
public function testColumnIndex() { |
|
|
|
$position = new Tile(2, 2); |
|
|
|
$position = new Position(2, 2); |
|
|
|
|
|
|
|
|
|
|
|
$this->assertEquals(1, $position->getColumnIndex()); |
|
|
|
$this->assertEquals(1, $position->getColumnIndex()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function testRowIndex() { |
|
|
|
public function testRowIndex() { |
|
|
|
$position = new Tile(2, 2); |
|
|
|
$position = new Position(2, 2); |
|
|
|
|
|
|
|
|
|
|
|
$this->assertEquals(1, $position->getRowIndex()); |
|
|
|
$this->assertEquals(1, $position->getRowIndex()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function testTheSameColumn() { |
|
|
|
public function testTheSameColumn() { |
|
|
|
$positionA = new Tile(2, 2); |
|
|
|
$positionA = new Position(2, 2); |
|
|
|
$positionB = new Tile(2, 2); |
|
|
|
$positionB = new Position(2, 2); |
|
|
|
|
|
|
|
|
|
|
|
$this->assertTrue($positionA->isTheSameColumn($positionB)); |
|
|
|
$this->assertTrue($positionA->isTheSameColumn($positionB)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function testTheSameRow() { |
|
|
|
public function testTheSameRow() { |
|
|
|
$positionA = new Tile(2, 2); |
|
|
|
$positionA = new Position(2, 2); |
|
|
|
$positionB = new Tile(2, 2); |
|
|
|
$positionB = new Position(2, 2); |
|
|
|
|
|
|
|
|
|
|
|
$this->assertTrue($positionA->isTheSameRow($positionB)); |
|
|
|
$this->assertTrue($positionA->isTheSameRow($positionB)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function testTheSamePosition() { |
|
|
|
public function testTheSamePosition() { |
|
|
|
$positionA = new Tile(2, 2); |
|
|
|
$positionA = new Position(2, 2); |
|
|
|
$positionB = new Tile(2, 2); |
|
|
|
$positionB = new Position(2, 2); |
|
|
|
|
|
|
|
|
|
|
|
$this->assertTrue($positionA->isTheSamePosition($positionB)); |
|
|
|
$this->assertTrue($positionA->isTheSamePosition($positionB)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function testNorthEastPosition() { |
|
|
|
public function testNorthEastPosition() { |
|
|
|
$position = new Tile(2, 2); |
|
|
|
$position = new Position(2, 2); |
|
|
|
$northEastPositionA = $position->getNorthEastPosition(); |
|
|
|
$northEastPositionA = $position->getNorthEastPosition(); |
|
|
|
$northEastPositionB = new Tile(1, 3); |
|
|
|
$northEastPositionB = new Position(1, 3); |
|
|
|
|
|
|
|
|
|
|
|
$this->assertTrue($northEastPositionA->isTheSamePosition($northEastPositionB)); |
|
|
|
$this->assertTrue($northEastPositionA->isTheSamePosition($northEastPositionB)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function testEastPosition() { |
|
|
|
public function testEastPosition() { |
|
|
|
$position = new Tile(2, 2); |
|
|
|
$position = new Position(2, 2); |
|
|
|
$northPositionA = $position->getEastPosition(); |
|
|
|
$northPositionA = $position->getEastPosition(); |
|
|
|
$northPositionB = new Tile(2, 3); |
|
|
|
$northPositionB = new Position(2, 3); |
|
|
|
|
|
|
|
|
|
|
|
$this->assertTrue($northPositionA->isTheSamePosition($northPositionB)); |
|
|
|
$this->assertTrue($northPositionA->isTheSamePosition($northPositionB)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function testSouthEastPosition() { |
|
|
|
public function testSouthEastPosition() { |
|
|
|
$position = new Tile(2, 2); |
|
|
|
$position = new Position(2, 2); |
|
|
|
$northPositionA = $position->getSouthEastPosition(); |
|
|
|
$northPositionA = $position->getSouthEastPosition(); |
|
|
|
$northPositionB = new Tile(3, 3); |
|
|
|
$northPositionB = new Position(3, 3); |
|
|
|
|
|
|
|
|
|
|
|
$this->assertTrue($northPositionA->isTheSamePosition($northPositionB)); |
|
|
|
$this->assertTrue($northPositionA->isTheSamePosition($northPositionB)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function testSouthPosition() { |
|
|
|
public function testSouthPosition() { |
|
|
|
$position = new Tile(2, 2); |
|
|
|
$position = new Position(2, 2); |
|
|
|
$northPositionA = $position->getSouthPosition(); |
|
|
|
$northPositionA = $position->getSouthPosition(); |
|
|
|
$northPositionB = new Tile(3, 2); |
|
|
|
$northPositionB = new Position(3, 2); |
|
|
|
|
|
|
|
|
|
|
|
$this->assertTrue($northPositionA->isTheSamePosition($northPositionB)); |
|
|
|
$this->assertTrue($northPositionA->isTheSamePosition($northPositionB)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function testsSouthWestPosition() { |
|
|
|
public function testsSouthWestPosition() { |
|
|
|
$position = new Tile(2, 2); |
|
|
|
$position = new Position(2, 2); |
|
|
|
$northPositionA = $position->getSouthWestPosition(); |
|
|
|
$northPositionA = $position->getSouthWestPosition(); |
|
|
|
$northPositionB = new Tile(3, 1); |
|
|
|
$northPositionB = new Position(3, 1); |
|
|
|
|
|
|
|
|
|
|
|
$this->assertTrue($northPositionA->isTheSamePosition($northPositionB)); |
|
|
|
$this->assertTrue($northPositionA->isTheSamePosition($northPositionB)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function testWestPosition() { |
|
|
|
public function testWestPosition() { |
|
|
|
$position = new Tile(2, 2); |
|
|
|
$position = new Position(2, 2); |
|
|
|
$northPositionA = $position->getWestPosition(); |
|
|
|
$northPositionA = $position->getWestPosition(); |
|
|
|
$northPositionB = new Tile(2, 1); |
|
|
|
$northPositionB = new Position(2, 1); |
|
|
|
|
|
|
|
|
|
|
|
$this->assertTrue($northPositionA->isTheSamePosition($northPositionB)); |
|
|
|
$this->assertTrue($northPositionA->isTheSamePosition($northPositionB)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function testNorthWestPosition() { |
|
|
|
public function testNorthWestPosition() { |
|
|
|
$position = new Tile(2, 2); |
|
|
|
$position = new Position(2, 2); |
|
|
|
$northPositionA = $position->getNorthWestPosition(); |
|
|
|
$northPositionA = $position->getNorthWestPosition(); |
|
|
|
$northPositionB = new Tile(1, 1); |
|
|
|
$northPositionB = new Position(1, 1); |
|
|
|
|
|
|
|
|
|
|
|
$this->assertTrue($northPositionA->isTheSamePosition($northPositionB)); |
|
|
|
$this->assertTrue($northPositionA->isTheSamePosition($northPositionB)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function testNorthPosition() { |
|
|
|
public function testNorthPosition() { |
|
|
|
$position = new Tile(2, 2); |
|
|
|
$position = new Position(2, 2); |
|
|
|
$northPositionA = $position->getNorthPosition(); |
|
|
|
$northPositionA = $position->getNorthPosition(); |
|
|
|
$northPositionB = new Tile(1, 2); |
|
|
|
$northPositionB = new Position(1, 2); |
|
|
|
|
|
|
|
|
|
|
|
$this->assertTrue($northPositionA->isTheSamePosition($northPositionB)); |
|
|
|
$this->assertTrue($northPositionA->isTheSamePosition($northPositionB)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function testOpenSpaceNeighbours() { |
|
|
|
public function testOpenSpaceNeighbours() { |
|
|
|
$position = new Tile(2, 2); |
|
|
|
$position = new Position(2, 2); |
|
|
|
// Neighbours from NE to N, in CW direction |
|
|
|
// Neighbours from NE to N, in CW direction |
|
|
|
$neighbours = [ |
|
|
|
$neighbours = [ |
|
|
|
new Tile(1, 3), |
|
|
|
new Position(1, 3), |
|
|
|
new Tile(2, 3), |
|
|
|
new Position(2, 3), |
|
|
|
new Tile(3, 3), |
|
|
|
new Position(3, 3), |
|
|
|
new Tile(3, 2), |
|
|
|
new Position(3, 2), |
|
|
|
new Tile(3, 1), |
|
|
|
new Position(3, 1), |
|
|
|
new Tile(2, 1), |
|
|
|
new Position(2, 1), |
|
|
|
new Tile(1, 1), |
|
|
|
new Position(1, 1), |
|
|
|
new Tile(1, 2), |
|
|
|
new Position(1, 2), |
|
|
|
]; |
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
$this->assertEquals($neighbours, $position->getNeighbouringPositions()); |
|
|
|
$this->assertEquals($neighbours, $position->getNeighbouringPositions()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function testCornerNeighbours() { |
|
|
|
public function testCornerNeighbours() { |
|
|
|
$position = new Tile(1, 1); |
|
|
|
$position = new Position(1, 1); |
|
|
|
// Return just E, SE and S neighbours |
|
|
|
// Return just E, SE and S neighbours |
|
|
|
$neighbours = [ |
|
|
|
$neighbours = [ |
|
|
|
new Tile(1, 2), |
|
|
|
new Position(1, 2), |
|
|
|
new Tile(2, 2), |
|
|
|
new Position(2, 2), |
|
|
|
new Tile(2, 1), |
|
|
|
new Position(2, 1), |
|
|
|
]; |
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
$this->assertEquals($neighbours, $position->getNeighbouringPositions()); |
|
|
|
$this->assertEquals($neighbours, $position->getNeighbouringPositions()); |
|
|
|