Exemplo n.º 1
0
 /**
  * Test VotePackage.
  *
  * @dataProvider dataVotes
  */
 public function testVotes($nbVotesUp, $nbVotesDown, $nbVotes)
 {
     $votes = [];
     for ($i = 0; $i < $nbVotesDown; ++$i) {
         $vote = $this->prophesize('Elcodi\\Component\\Comment\\Entity\\Interfaces\\VoteInterface');
         $vote->getType()->willReturn(Vote::DOWN);
         $votes[] = $vote->reveal();
     }
     for ($i = 0; $i < $nbVotesUp; ++$i) {
         $vote = $this->prophesize('Elcodi\\Component\\Comment\\Entity\\Interfaces\\VoteInterface');
         $vote->getType()->willReturn(Vote::UP);
         $votes[] = $vote->reveal();
     }
     $votePackage = VotePackage::create($votes);
     $this->assertEquals($nbVotesDown, $votePackage->getNbDownVotes());
     $this->assertEquals($nbVotesUp, $votePackage->getNbUpVotes());
     $this->assertEquals($nbVotes, $votePackage->getNbVotes());
 }
Exemplo n.º 2
0
 /**
  * Get comment votes
  *
  * @param CommentInterface $comment Comment
  *
  * @return VotePackage Vote package
  */
 public function getCommentVotes(CommentInterface $comment)
 {
     /**
      * @var VoteInterface[] $votes
      */
     $votes = $this->commentVoteObjectDirector->findBy(['comment' => $comment]);
     return VotePackage::create($votes);
 }