コード例 #1
0
 function it_does_not_get_the_user_because_the_email_does_not_exist(UserRepository $repository, UserOfEmailQuery $query)
 {
     $query->email()->shouldBeCalled()->willReturn('*****@*****.**');
     $email = new UserEmail('*****@*****.**');
     $repository->userOfEmail($email)->shouldBeCalled()->willReturn(null);
     $this->shouldThrow(UserDoesNotExistException::class)->during__invoke($query);
 }
コード例 #2
0
ファイル: UserOfEmailHandler.php プロジェクト: bengor/user
 /**
  * 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();
 }