/** * Handles a CreateGameCommand * * @param CreateGameCommand $command * @return void */ public function handleCreateGameCommand(CreateGameCommand $command) { ContextContainer::setContext($command->getContext()); try { $miniGame = $this->builder->createMiniGame($command->getGameId(), $command->getPlayerId(), $command->getOptions()); $this->gameManager->save($miniGame); } catch (\Exception $e) { $this->errorHandler->handle(new UnableToCreateGameEvent($command->getGameId(), $command->getPlayerId(), $e->getMessage()), $command->getContext()); } ContextContainer::reset(); }
private function givenGameCannotBeCreated() { $this->gameBuilder->shouldReceive('createMiniGame')->andThrow(\Exception::class); }