public function testEndIsReturned() { $period = new LeaguePeriod(new \DateTime(), 2013, 12); $this->assertSame('2013-12-31', $period->getEnd()->format('Y-m-d')); }
/** * Get all players who have played a match (yet) in the tournament * * @param int $tournament Tournament Id * @param LeaguePeriod $period * * @return ArrayCollection List of players that have already done a match */ public function getActivePlayers($tournament, $period) { $query = $this->_em->createQuery('SELECT m FROM Application\\Model\\Entity\\SingleMatch m WHERE m.date >= :start AND m.date <= :end AND m.tournament = :tournament'); $query->setParameters(array('start' => $period->getStart()->format('Y-m-d H:i:s'), 'end' => $period->getEnd()->format('Y-m-d H:i:s'), 'tournament' => $tournament)); $participants = array(); /** @var $results \Application\Model\Entity\SingleMatch[] */ $results = $query->getResult(); foreach ($results as $result) { $participants[$result->getPlayer1()->getId()] = $result->getPlayer1(); $participants[$result->getPlayer2()->getId()] = $result->getPlayer2(); } $participantCollection = new ArrayCollection(array_values($participants)); return $participantCollection; }