コード例 #1
0
ファイル: LogOutUserHandler.php プロジェクト: bengor/user
 /**
  * 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
ファイル: LogOutUserHandlerSpec.php プロジェクト: bengor/user
 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);
 }