Beispiel #1
0
 function it_gets_the_user(UserOfEmailQuery $query, UserRepository $repository, User $user, UserDataTransformer $dataTransformer, \DateTimeImmutable $createdOn, \DateTimeImmutable $lastLogin, \DateTimeImmutable $updatedOn)
 {
     $query->email()->shouldBeCalled()->willReturn('*****@*****.**');
     $email = new UserEmail('*****@*****.**');
     $repository->userOfEmail($email)->shouldBeCalled()->willReturn($user);
     $dataTransformer->write($user)->shouldBeCalled();
     $dataTransformer->read()->shouldBeCalled()->willReturn(['id' => 'user-id', 'confirmation_token' => null, 'created_on' => $createdOn, 'email' => '*****@*****.**', 'last_login' => $lastLogin, 'password' => 'encoded-password', 'remember_password_token' => null, 'roles' => ['ROLE_USER'], 'updated_on' => $updatedOn]);
     $this->__invoke($query)->shouldReturn(['id' => 'user-id', 'confirmation_token' => null, 'created_on' => $createdOn, 'email' => '*****@*****.**', 'last_login' => $lastLogin, 'password' => 'encoded-password', 'remember_password_token' => null, 'roles' => ['ROLE_USER'], 'updated_on' => $updatedOn]);
 }
Beispiel #2
0
 /**
  * Handles the given query.
  *
  * @param UserOfEmailQuery $aQuery The query
  *
  * @throws UserDoesNotExistException when the user does not exist
  *
  * @return mixed
  */
 public function __invoke(UserOfEmailQuery $aQuery)
 {
     $user = $this->repository->userOfEmail(new UserEmail($aQuery->email()));
     if (null === $user) {
         throw new UserDoesNotExistException();
     }
     $this->dataTransformer->write($user);
     return $this->dataTransformer->read();
 }
 /**
  * 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();
 }
Beispiel #4
0
 /**
  * {@inheritdoc}
  */
 public function loadUserByUsername($username)
 {
     try {
         $user = $this->userOfEmailHandler->__invoke(new UserOfEmailQuery($username));
         $this->dataTransformer->write($user);
         return $this->dataTransformer->read();
         // Catches any kind of exception that comes from domain or a service layer, and it throws
         // for Symfony's UserInterface, a suitable exception like "UsernameNotFoundException".
     } catch (UserDoesNotExistException $exception) {
         throw new UsernameNotFoundException();
     }
 }