/** * @param int $gameId * * @return Domain\Game * * @throws Domain\DominoException */ private function loadGame($gameId) { $game = $this->gameRepository->findById($gameId); if ($game === null) { throw new DominoException('could not find game with id ' . $gameId); } return $game; }
public function testPlayCallsPlayOnPlayer() { $game = $this->createGameMock(42); $player = $this->createPlayerMock($game, 1, 'player 1'); $this->gameRepositoryMock->expects($this->once())->method('findById')->with($this->identicalTo(42))->willReturn($game); $game->expects($this->any())->method('getPlayerByPlayerNumber')->with($this->equalTo(3))->willReturn($player); $player->expects($this->once())->method('play')->with($this->equalToPlay(new Domain\Play(1, new Domain\Stone(6, 6), Domain\Table::SIDE_LEFT))); $turnNumber = 1; $playerNumber = 3; $play = new Dto\Play($turnNumber, new Dto\Stone(6, 6), Dto\Play::SIDE_LEFT); $this->gameService->play(42, $playerNumber, $play); }