/** * Remove (soft) existing editorial comment * @param EditorialComment $comment * @param User $user */ public function remove(EditorialComment $comment, User $user) { if ($comment->getUser()->getId() == $user->getId() || $user->isAdmin()) { $comment->setIsActive(false); } else { throw new AccessDeniedHttpException("User is not allowed to remove comment"); } $this->em->flush(); return true; }
public function it_should_remove_comment(EditorialComment $comment, User $user) { $comment->getUser()->willReturn($user); $comment->setIsActive(Argument::type('bool'))->willReturn(true); $this->remove($comment, $user)->shouldReturn(true); }