public function getVotes(Motion $motion) { $statement = $this->connection->prepareStatement('SELECT COUNT(*) as nb_votes, choice FROM motions_votes WHERE motion_id = :motion_id GROUP BY choice', ['motion_id' => $motion->getId()]); $votes = ['positive' => 0, 'negative' => 0]; while ($data = $statement->fetch(\PDO::FETCH_ASSOC)) { $votes[(bool) $data['choice'] ? 'positive' : 'negative'] = (int) $data['nb_votes']; } return $votes; }
public function createMotionMock(Motion &$motion) { $motion->setId(2); }