/**
  * @test
  */
 public function itShouldBuildTheCommand()
 {
     $command = CreateGameCommand::create($this->gameId, $this->playerId, $this->gameOptions, $this->context);
     $this->assertEquals($this->gameId, $command->getGameId());
     $this->assertEquals($this->playerId, $command->getPlayerId());
     $this->assertEquals($this->gameOptions, $command->getOptions());
     $this->assertEquals($this->context, $command->getContext());
     $this->assertEquals(CreateGameCommand::NAME, $command->getCommandName());
 }
 /**
  * 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();
 }
Exemplo n.º 3
0
 /**
  * @test
  */
 public function itShouldFailCreatingGame()
 {
     $command = CreateGameCommand::create($this->gameId, $this->playerId, $this->options, $this->context);
     $this->givenGameCannotBeCreated();
     $this->assertErrorWillBeHandled();
     $this->assertGameStateWontChange();
     $this->miniGameCommandHandler->handleCreateGameCommand($command);
 }