Exemplo n.º 1
0
 /**
  * Returns number of affected rows.
  * 
  * @param \Wonderland\Application\Model\Member $member
  * @param int                                  $motionId
  * @param string                               $vote
  */
 public function voteMotion(Member $member, $motionId, $vote)
 {
     if ($this->hasAlreadyVoted($motionId, $member->getId())) {
         throw new BadRequestException('You already voted this motion');
     }
     $date = date('Y-m-d h-i-s');
     $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : 'inconnue';
     try {
         $this->repository->createVote($motionId, $member->getId(), $member->getIdentity(), $date, $ip, $vote);
     } catch (\PDOException $exception) {
         throw new RuntimeException("The vote failed : {$exception->getMessage()}");
     }
 }
 public function testCreateVote()
 {
     $this->repository->createVote(1, 2, 'Alexander', '2016-06-08 14:50:35', '127.0.0.1', 1);
     $this->assertTrue($this->repository->hasAlreadyVoted(1, 2));
 }