Esempio n. 1
0
 function it_removes_user(RemoveUserCommand $command, UserRepository $repository, User $user)
 {
     $command->id()->shouldBeCalled()->willReturn('user-id');
     $repository->userOfId(new UserId('user-id'))->shouldBeCalled()->willReturn($user);
     $repository->remove($user)->shouldBeCalled();
     $this->__invoke($command);
 }
Esempio n. 2
0
 /**
  * Handles the given command.
  *
  * @param RemoveUserCommand $aCommand The command
  *
  * @throws UserDoesNotExistException when the user does not exist
  */
 public function __invoke(RemoveUserCommand $aCommand)
 {
     $user = $this->repository->userOfId(new UserId($aCommand->id()));
     if (null === $user) {
         throw new UserDoesNotExistException();
     }
     $this->repository->remove($user);
 }