コード例 #1
0
 function it_does_not_get_the_user_because_the_invitation_token_is_expired(UserRepository $repository, UserOfInvitationTokenQuery $query, User $user)
 {
     $query->invitationToken()->shouldBeCalled()->willReturn('invitation-token');
     $token = new UserToken('invitation-token');
     $repository->userOfInvitationToken($token)->shouldBeCalled()->willReturn($user);
     $user->isInvitationTokenExpired()->shouldBeCalled()->willReturn(true);
     $this->shouldThrow(UserTokenExpiredException::class)->during__invoke($query);
 }
コード例 #2
0
 /**
  * Handles the given query.
  *
  * @param UserOfInvitationTokenQuery $aQuery The query
  *
  * @throws UserDoesNotExistException when the user does not exist
  * @throws UserTokenExpiredException when the token is expired
  *
  * @return mixed
  */
 public function __invoke(UserOfInvitationTokenQuery $aQuery)
 {
     $user = $this->repository->userOfInvitationToken(new UserToken($aQuery->invitationToken()));
     if (null === $user) {
         throw new UserDoesNotExistException();
     }
     if ($user->isInvitationTokenExpired()) {
         throw new UserTokenExpiredException();
     }
     $this->dataTransformer->write($user);
     return $this->dataTransformer->read();
 }