public function testUpdateScore() { //this test depend the system parametes points to winner and loser values $rank[1] = array('matchsWon' => 0, 'setsWon' => 0, 'setsLost' => 0, 'gamesWon' => 0, 'gamesLost' => 0, 'points' => 0); $rank[2] = array('matchsWon' => 0, 'setsWon' => 0, 'setsLost' => 0, 'gamesWon' => 0, 'gamesLost' => 0, 'points' => 0); $rankResult[1] = array('matchsWon' => 2, 'setsWon' => 5, 'setsLost' => 3, 'gamesWon' => 35, 'gamesLost' => 38, 'points' => 6); $rankResult[2] = array('matchsWon' => 1, 'setsWon' => 3, 'setsLost' => 5, 'gamesWon' => 38, 'gamesLost' => 35, 'points' => 3); $gameService = new GameService(); $gameService->setManager($this->em); $rank = $gameService->updateScore("6/3 2/6 7/5", $rank, 1, 2); $rank = $gameService->updateScore("6/4 7/5", $rank, 1, 2); $rank = $gameService->updateScore("0/6 6/3 1/6", $rank, 1, 2); $this->assertEquals($rank, $rankResult); }
public function calculateClassficationByGroup($inscriptions, $group) { $gameService = new GameService(); $gameService->setManager($this->em); $rank = array(); foreach ($inscriptions as $inscription) { $rank[$inscription->getPair()->getId()] = array('matchsWon' => 0, 'setsWon' => 0, 'setsLost' => 0, 'gamesWon' => 0, 'gamesLost' => 0, 'points' => 0, 'pair' => $inscription->getPair()->getId()); } $games = $gameService->getGamesByGroup($group->getId()); foreach ($games as $game) { if (!is_null($game->getScore()) && $game->getScore() != '') { $rank = $gameService->updateScore($game->getScore(), $rank, $game->getPair1()->getId(), $game->getPair2()->getId()); } } if (!is_null($rank)) { $rank = $this->sortByScore($rank); if (Literals::doubleTieResolveByGame == "true") { $rank = $this->resolveDobulesDraws($rank, $games); } $position = 0; foreach ($rank as $r) { foreach ($inscriptions as $inscription) { if ($inscription->getPair()->getId() == $r['pair']) { $inscription->setClassifiedPositionInGroup($position); $this->em->persist($inscription); $position = $position + 1; } } } } return $rank; }