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