/**
  * @test
  */
 public function itShouldBuildTheCommand()
 {
     $command = GameMoveCommand::create($this->gameId, $this->playerId, $this->move, $this->context);
     $this->assertEquals($this->playerId, $command->getPlayerId());
     $this->assertEquals($this->gameId, $command->getGameId());
     $this->assertEquals($this->move, $command->getMove());
     $this->assertEquals($this->context, $command->getContext());
     $this->assertEquals(GameMoveCommand::NAME, $command->getCommandName());
 }
 /**
  * Handles a GameMoveCommand
  *
  * @param  GameMoveCommand $command
  * @return void
  */
 public function handleGameMoveCommand(GameMoveCommand $command)
 {
     ContextContainer::setContext($command->getContext());
     try {
         $miniGame = $this->gameManager->load($command->getGameId());
         $miniGame->play($command->getPlayerId(), $command->getMove());
         $this->gameManager->save($miniGame);
     } catch (\Exception $e) {
         $this->errorHandler->handle(new MiniGameAppErrorEvent($command->getGameId(), $command->getPlayerId(), $e->getMessage()), $command->getContext());
     }
     ContextContainer::reset();
 }
 /**
  * @test
  */
 public function itShouldFailPlayingIfGameDoesNotExist()
 {
     $command = GameMoveCommand::create($this->gameId, $this->playerId, $this->move, $this->context);
     $this->givenGameDoesNotExist();
     $this->assertErrorWillBeHandled();
     $this->assertGameStateWontChange();
     $this->miniGameCommandHandler->handleGameMoveCommand($command);
 }