/** * Checks if ships are set correctly * * Validates coordinates of all ships' masts, checks the number, * sizes and shapes of the ships, and potential edge connections between them. * * @param array $ships Ships set by the player (Example: ['A1','B4','J10',...]) * @throws InvalidShipsException */ protected function validateShips(array $ships) { $shipsCollection = new CoordsCollection($ships); $shipsCollection->sort(); // required for validateEdgeConnections and validateShipsTypes $this->coordsManager->validateCoordsArray($shipsCollection->toArray()); $this->validateShipsLength($shipsCollection); $this->validateEdgeConnections($shipsCollection); $this->validateShipsTypes($shipsCollection); }
/** * @expectedException \AppBundle\Exception\InvalidCoordinatesException * @expectedExceptionMessage Invalid coordinates provided * @dataProvider incorrectCoordsArrayProvider * @param array $coords */ public function testValidateCoordsArrayIncorrect(array $coords) { $this->coordsManager->validateCoordsArray($coords); }