/**
  * Handle switching in to a different account
  *
  * @param string                                                                           $token
  * @param \Tectonic\Shift\Modules\Authentication\Contracts\SwitchAccountResponderInterface $responder
  *
  * @return mixed
  */
 public function switchAccount($token, SwitchAccountResponderInterface $responder)
 {
     try {
         $command = new SwitchAccountCommand($token);
         $this->commandBus->execute($command);
         return $responder->onSuccess();
     } catch (TokenNotFoundException $e) {
         return $responder->onFailure();
     }
 }
 public function testExecution()
 {
     $command = m::mock('Tectonic\\Application\\Commanding\\Command');
     $container = m::mock('Illuminate\\Container\\Container')->makePartial();
     $translator = m::mock('Tectonic\\Application\\Commanding\\CommandTranslator')->makePartial();
     $logger = m::spy('Illuminate\\Log\\Writer');
     $translator->shouldReceive('getCommandHandler')->with($command)->andReturn('handler');
     $container->shouldReceive('make')->once()->with('handler')->andReturn($container);
     $container->shouldReceive('handle')->once()->with($command)->andReturn('execution result');
     $commandBus = new DefaultCommandBus($container, $translator, $logger);
     $response = $commandBus->execute($command);
     $this->assertEquals($response, 'execution result');
     $logger->shouldHaveReceived('info')->once();
 }
Example #3
0
 /**
  * When a user has registered, we need to send them a confirmation email. This email
  * contains their confirmation token and is a call to action.
  *
  * @param UserHasRegistered $event
  */
 public function whenUserHasRegistered(UserHasRegistered $event)
 {
     $this->commandBus->execute(new SendRegistrationEmailCommand($event->user));
 }
 /**
  * Execute the command, but first run it through our custom validation command handlers.
  *
  * @param Command $command
  * @return mixed
  */
 public function execute(Command $command)
 {
     $this->validate($command);
     return $this->bus->execute($command);
 }
Example #5
0
 public function whenAccountWasCreated(AccountWasCreated $event)
 {
     $command = new SetupDefaultRolesCommand($event->account);
     $this->commandBus->execute($command);
 }