Esempio n. 1
0
 function it_does_not_get_the_user_because_the_id_does_not_exist(UserRepository $repository, UserOfIdQuery $query)
 {
     $query->id()->shouldBeCalled()->willReturn('user-id');
     $id = new UserId('user-id');
     $repository->userOfId($id)->shouldBeCalled()->willReturn(null);
     $this->shouldThrow(UserDoesNotExistException::class)->during__invoke($query);
 }
Esempio n. 2
0
 /**
  * Handles the given query.
  *
  * @param UserOfIdQuery $aQuery The query
  *
  * @throws UserDoesNotExistException when the user does not exist
  *
  * @return mixed
  */
 public function __invoke(UserOfIdQuery $aQuery)
 {
     $user = $this->repository->userOfId(new UserId($aQuery->id()));
     if (null === $user) {
         throw new UserDoesNotExistException();
     }
     $this->dataTransformer->write($user);
     return $this->dataTransformer->read();
 }