diff --git a/models/Player.php b/models/Player.php index 009dd6f8..d831d50a 100644 --- a/models/Player.php +++ b/models/Player.php @@ -360,6 +360,10 @@ public function invalidateMatchFromCache(Match $match) $seasonKey = $this->buildSeasonKeyFromTimestamp($match->getTimestamp()); $seasonElo = null; + if (!isset($this->eloSeasonHistory[$seasonKey][$match->getId()])) { + return; + } + $eloChangelogIndex = array_search($match->getId(), array_keys($this->eloSeasonHistory[$seasonKey])); $slicedChangeLog = array_slice($this->eloSeasonHistory[$seasonKey], 0, $eloChangelogIndex, true); diff --git a/tests/ModelTests/MatchEloTest.php b/tests/ModelTests/MatchEloTest.php index e2a52da7..7acca69b 100644 --- a/tests/ModelTests/MatchEloTest.php +++ b/tests/ModelTests/MatchEloTest.php @@ -67,7 +67,6 @@ public function testEloRecalculation() $matchToEdit = $matches[3]; - $matchResult = $matchToEdit->getMatchDescription($team); $scoreTeamA = $matchToEdit->getScore($matchToEdit->getTeamA()); $scoreTeamB = $matchToEdit->getScore($matchToEdit->getTeamB()); @@ -78,16 +77,8 @@ public function testEloRecalculation() $newLeaderElo = Player::get($team->getLeader())->getElo(); $newTeamElo = Team::get($team->getId())->getElo(); - if ($matchResult === 'win') { - $this->assertLessThan($preRecalcLeaderElo, $newLeaderElo); - $this->assertLessThan($preRecalcTeamElo, $newTeamElo); - } elseif ($matchResult === 'loss') { - $this->assertGreaterThan($preRecalcLeaderElo, $newLeaderElo); - $this->assertGreaterThan($preRecalcTeamElo, $newTeamElo); - } else { - $this->assertEquals($preRecalcLeaderElo, $newLeaderElo); - $this->assertEquals($preRecalcTeamElo, $newTeamElo); - } + $this->assertNotEquals($preRecalcLeaderElo, $newLeaderElo); + $this->assertNotEquals($preRecalcTeamElo, $newTeamElo); } /**