예제 #1
0
 /**
  * Handles the given command.
  *
  * @param ByInvitationSignUpUserCommand $aCommand The command
  *
  * @throws UserDoesNotExistException when the user does not exist
  */
 public function __invoke(ByInvitationSignUpUserCommand $aCommand)
 {
     $user = $this->userRepository->userOfInvitationToken(new UserToken($aCommand->invitationToken()));
     if (null === $user) {
         throw new UserDoesNotExistException();
     }
     $user->changePassword(UserPassword::fromPlain($aCommand->password(), $this->encoder));
     $user->acceptInvitation();
     $this->userRepository->persist($user);
 }
 function it_does_not_sign_up_because_user_does_not_exist(ByInvitationSignUpUserCommand $command, UserRepository $repository)
 {
     $command->invitationToken()->shouldBeCalled()->willReturn('invitation-token');
     $repository->userOfInvitationToken(new UserToken('invitation-token'))->shouldBeCalled()->willReturn(null);
     $this->shouldThrow(UserDoesNotExistException::class)->during__invoke($command);
 }