/**
  * 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);
 }
 public function testSort()
 {
     // make sure it's natural sort (A1, A2, A10 vs. A1, A10, A2)
     $coordsArray = ['A1', 'J10', 'J1', 'B2', 'A10', 'A2', 'A9'];
     $coordsCollection = new CoordsCollection($coordsArray);
     $coordsCollection->sort();
     $coordsArraySorted = ['A1', 'A2', 'A9', 'A10', 'B2', 'J1', 'J10'];
     foreach ($coordsCollection as $key => $coords) {
         $this->assertEquals($coordsArraySorted[$key], $coords);
     }
 }