Exemplo 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);
     }
 }
Exemplo n.º 2
0
 public function testSaveScheduleIdInt()
 {
     $sheduleService = new ScheduleService();
     $sheduleService->setManager($this->em);
     $params = array('tournament' => $this->tournament1->getId());
     $schedule = $sheduleService->saveSchedule($params);
     $this->assertContains('ok', json_encode($schedule));
     $this->em->remove($schedule['message']);
 }