/**
  * @see     CellModel::getChangedCells
  * @test
  *
  * @depends switchPhase
  * @depends switchPhaseWithAdditionalFlag
  */
 public function getChangedCells()
 {
     $this->assertContainsOnlyInstancesOf(Cell::class, CellModel::getChangedCells());
     $this->assertGreaterThanOrEqual(1, count(CellModel::getChangedCells()));
 }
 /**
  * @see GameControllerTest::successfulTurnAction
  * @see GameControllerTest::unsuccessfulTurnActionOnDeadCell
  *
  * @ApiDoc(
  *      section = "Game:: Mechanics",
  *      description = "process game turn by cellId",
  *      output = "EM\GameBundle\Response\GameTurnResponse",
  *      statusCodes = {
  *          200 = "successful turn",
  *          404 = "cell do not exists",
  *          422 = "cell already flagged as DEAD"
  *      }
  * )
  *
  * @param int $cellId
  *
  * @return Response
  * @throws CellException
  * @throws GameProcessorException
  */
 public function turnAction(int $cellId) : Response
 {
     if (null === ($cell = $this->getDoctrine()->getRepository('GameBundle:Cell')->find($cellId))) {
         throw new CellException(Response::HTTP_NOT_FOUND, "cell: {$cellId} do not exist");
     }
     if ($cell->hasFlag(CellModel::FLAG_DEAD)) {
         throw new CellException(Response::HTTP_UNPROCESSABLE_ENTITY, "cell: {$cellId} already flagged as *DEAD*");
     }
     $game = $this->get('battleship_game.service.game_processor')->processTurn($cell);
     $om = $this->getDoctrine()->getManager();
     foreach (CellModel::getChangedCells() as $cell) {
         $om->persist($cell);
     }
     $om->flush();
     return $this->prepareSerializedResponse(new GameTurnResponse($game, CellModel::getChangedCells()));
 }