/**
  * @see BattlefieldModel::getLiveCells
  * @test
  */
 public function getLiveCells()
 {
     $battlefield = MockFactory::getBattlefieldMock();
     $this->assertCount(49, BattlefieldModel::getLiveCells($battlefield));
     $battlefield->getCellByCoordinate('A1')->addFlag(CellModel::FLAG_DEAD);
     $this->assertCount(48, BattlefieldModel::getLiveCells($battlefield));
 }
 /**
  * @param Battlefield $battlefield
  *
  * @return Cell
  * @throws AIException
  * @throws CellException
  */
 public function processCPUTurn(Battlefield $battlefield) : Cell
 {
     $cells = $this->strategyService->chooseCells($battlefield);
     try {
         return self::pickCellToAttack($cells);
     } catch (CellException $e) {
         $cells = BattlefieldModel::getLiveCells($battlefield);
         return self::pickCellToAttack($cells);
     }
 }
         $cells = BattlefieldModel::getLiveCells($this->battlefield);
         expect($cells)->toBeA('array')->toHaveLength(49);
         $this->iterateRecievedCells($cells);
     });
     it('should return 48 cells from 7x7 battlefield 48 of them not flagged with CellModel::FLAG_DEAD', function () {
         $this->battlefield->getCellByCoordinate('A1')->addFlag(CellModel::FLAG_DEAD);
         $cells = BattlefieldModel::getLiveCells($this->battlefield);
         expect($cells)->toBeA('array')->toHaveLength(48);
         $this->iterateRecievedCells($cells);
     });
     it('should return empty array from 7x7 battlefield all of them flagged with CellModel::FLAG_DEAD', function () {
         /** @var Cell $cell */
         foreach ($this->battlefield->getCells() as $cell) {
             $cell->addFlag(CellModel::FLAG_DEAD);
         }
         $cells = BattlefieldModel::getLiveCells($this->battlefield);
         expect($cells)->toBeA('array')->toHaveLength(0);
     });
 });
 /**
  * @see BattlefieldModel::hasUnfinishedShips
  */
 describe('::hasUnfinishedShips - should return true if Battlefield contains cells flagged with CellModel::FLAG_SHIP and not flagged with CellModel::FLAG_DEAD', function () {
     it('should return false', function () {
         $battlefield = MockFactory::getBattlefieldMock();
         expect(BattlefieldModel::hasUnfinishedShips($battlefield))->toBe(false);
     });
     it('should return true', function () {
         $battlefield = MockFactory::getBattlefieldMock();
         $battlefield->getCellByCoordinate('A1')->addFlag(CellModel::FLAG_SHIP);
         expect(BattlefieldModel::hasUnfinishedShips($battlefield))->toBe(true);
 /**
  * invoke game processing method on Unfinished Game
  *
  * @see     GameProcessor::processTurn
  * @test
  *
  * @depends processTurnOnFinishedGame
  */
 public function processTurnToNotWin()
 {
     $game = MockFactory::getGameMock();
     $aiBattlefield = $game->getBattlefields()[0];
     $aiBattlefield->setPlayer(MockFactory::getAIPlayerMock(''));
     foreach ($game->getBattlefields() as $battlefield) {
         $battlefield->getCellByCoordinate('A1')->addFlag(CellModel::FLAG_SHIP);
         $battlefield->getCellByCoordinate('A2')->addFlag(CellModel::FLAG_SHIP);
     }
     $game = static::$gameProcessor->processTurn($aiBattlefield->getCellByCoordinate('A1'));
     foreach ($game->getBattlefields() as $battlefield) {
         $this->assertCount(48, BattlefieldModel::getLiveCells($battlefield));
         /** as one cell should be dead */
         $this->assertTrue(BattlefieldModel::hasUnfinishedShips($battlefield));
     }
     $this->assertTrue($aiBattlefield->getCellByCoordinate('A1')->hasFlag(CellModel::FLAG_DEAD_SHIP));
     $this->assertNull($game->getResult());
 }