public function testGetTotalScoreReturnNegativeScore() { $comment = new Comment(); $comment->addRating($this->badRating); $actual = $comment->getTotalScore(); $this->assertEquals(-1, $actual); }
public function addRating(Request $request, \AppBundle\Entity\Comment $comment) { if ($this->validateRequest($request)) { $userId = $request->request->get('user'); $thumbsUp = $request->request->get('rating'); $user = $this->userRepo->findOneById($userId); $comment->addRating($this->createRating($user, $thumbsUp)); $this->commentRepo->save($comment); return true; } return false; }