Esempio n. 1
0
 public function saveGamesTournament($params)
 {
     if (!empty($params['tournamentId'])) {
         $tournamentService = new TournamentService();
         $tournamentService->setManager($this->em);
         $tournament = $tournamentService->getTournament($params['tournamentId']);
         $allGamesToReturnInCategory = array();
         if ($tournament instanceof Tournament) {
             $inscriptionService = new InscriptionService();
             $inscriptionService->setManager($this->em);
             $inscriptionsTournament = $inscriptionService->getInscriptionsByGroupForATournament($params['tournamentId'], null);
             foreach ($inscriptionsTournament as $categoryKey => $inscriptionsCategory) {
                 $gamesForGroup = array();
                 foreach ($inscriptionsCategory as $groupKey => $inscriptionsGroup) {
                     $gamesForGroup[] = $this->doGamesByGroup($inscriptionsGroup);
                 }
                 $allGamesToReturnInCategory[$categoryKey] = $gamesForGroup;
             }
             $scheduleService = new ScheduleService();
             $scheduleService->setManager($this->em);
             $scheduleService->setDatesToMatchsInTournament($this->getGamesByTournamentInArray($tournament->getId()), $inscriptionService->getInscriptionsByTournamentInArray($tournament->getId()), $tournament->getId());
             $tournament->setStatus($this->statusService->getStatus('tournament', Literals::Matchs_DoneTournamentStatus));
             $this->em->persist($tournament);
             $this->em->flush();
             return array('result' => 'ok', 'message' => $this->getGamesByTournament($tournament->getId()));
         } else {
             return array('result' => 'fail', 'message' => Literals::TournamentIdNotCorrect);
         }
     } else {
         return array('result' => 'fail', 'message' => Literals::TournamentIdNotCorrect);
     }
 }
Esempio n. 2
0
 public function testSetDatesToMatchsInTournament()
 {
     $scheduleService = new ScheduleService();
     $scheduleService->setManager($this->em);
     $gamesInTournament = array($this->game1, $this->game2, $this->game3, $this->game4, $this->game5);
     $scheduleItem = $scheduleService->setDatesToMatchsInTournament($gamesInTournament, null, $this->tournament->getId());
     $this->assertContains('negro', $scheduleItem);
     $this->assertContains('amarillo', $scheduleItem);
     $this->assertContains('blanco', $scheduleItem);
     $this->assertContains('rojo', $scheduleItem);
     $this->assertContains('gris', $scheduleItem);
 }