示例#1
0
 /**
  * Handles the given command.
  *
  * @param LogOutUserCommand $aCommand The command
  *
  * @throws UserDoesNotExistException when the user does not exist
  */
 public function __invoke(LogOutUserCommand $aCommand)
 {
     $user = $this->repository->userOfId(new UserId($aCommand->id()));
     if (null === $user) {
         throw new UserDoesNotExistException();
     }
     $user->logout();
     $this->repository->persist($user);
 }
示例#2
0
 function it_does_not_logout_unknown_user(UserRepository $repository, LogOutUserCommand $command)
 {
     $command->id()->shouldBeCalled()->willReturn('user-id');
     $repository->userOfId(new UserId('user-id'))->shouldBeCalled()->willReturn(null);
     $this->shouldThrow(UserDoesNotExistException::class)->during__invoke($command);
 }