Exemplo n.º 1
0
 /**
  * Handles the given command.
  *
  * @param LogInUserCommand $aCommand The command
  *
  * @throws UserDoesNotExistException when the user does not exist
  */
 public function __invoke(LogInUserCommand $aCommand)
 {
     $user = $this->repository->userOfEmail(new UserEmail($aCommand->email()));
     if (null === $user) {
         throw new UserDoesNotExistException();
     }
     $user->login($aCommand->password(), $this->encoder);
     $this->repository->persist($user);
 }
Exemplo n.º 2
0
 function it_does_not_log_if_user_does_not_exist(UserRepository $repository, LogInUserCommand $command)
 {
     $command->email()->shouldBeCalled()->willReturn('*****@*****.**');
     $repository->userOfEmail(new UserEmail('*****@*****.**'))->shouldBeCalled()->willReturn(null);
     $this->shouldThrow(UserDoesNotExistException::class)->during__invoke($command);
 }