コード例 #1
0
ファイル: CommentTest.php プロジェクト: sonu27/REST-api-test
 public function testGetTotalScoreReturnNegativeScore()
 {
     $comment = new Comment();
     $comment->addRating($this->badRating);
     $actual = $comment->getTotalScore();
     $this->assertEquals(-1, $actual);
 }
コード例 #2
0
ファイル: Rating.php プロジェクト: sonu27/REST-api-test
 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;
 }