/** * @dataProvider getNewRatingsData */ public function testGetNewRatings($ratingA, $ratingB, $result, $expectedNewRatingA, $expectedNewRatingB, EloCalculatorInterface $eloCalculator) { if ($result === AbstractEloCalculator::WIN) { $scoreA = AbstractEloCalculator::WIN; $scoreB = AbstractEloCalculator::LOSE; } elseif ($result === AbstractEloCalculator::LOSE) { $scoreA = AbstractEloCalculator::LOSE; $scoreB = AbstractEloCalculator::WIN; } else { $scoreA = AbstractEloCalculator::DRAW; $scoreB = AbstractEloCalculator::DRAW; } $participantA = new Participant(); $participantA->setRating($ratingA); $participantA->setScore($scoreA); $participantB = new Participant(); $participantB->setRating($ratingB); $participantB->setScore($scoreB); list($newRatingA, $newRatingB) = $eloCalculator->getNewRatings($participantA, $participantB); $this->assertSame($expectedNewRatingA, $newRatingA); $this->assertSame($expectedNewRatingB, $newRatingB); }
/** * @param ParticipantInterface $team1Participant * @param ParticipantInterface $team2Participant * @return float */ private function getTeam1ParticipantNewRating(ParticipantInterface $team1Participant, ParticipantInterface $team2Participant) { $newRatings = $this->eloCalculator->getNewRatings($team1Participant, $team2Participant); return $newRatings[0]; }