Skip to content

Improve RejudgingServiceTest. #2963

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions webapp/tests/Unit/Service/RejudgingServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,16 @@ public function testUpdateFirstToSolve(): void
$problem = $entityManager->getRepository(Problem::class)->findOneBy(['externalid' => 'hello']);
$contestProblem = $problem->getContestProblems()->first();

// Get the initial scoreboard. team 1 should have the FTS for the problem, team 2 shouldn't
foreach ([$team1, $team2] as $team) {
$scoreboardService->calculateScoreRow($contest, $team, $problem);
$scoreboardService->calculateTeamRank($contest, $team);
}

$scoreboard = $scoreboardService->getScoreboard($contest, true);
// Get the initial scoreboard.
$scoreboardService->refreshCache($contest);
$scoreboard = $scoreboardService->getScoreboard($contest, jury: true);

// The fixture above sets up that $team1 solved the problem, $team2 didn't.
// So $team1 also solved it first.
static::assertTrue($scoreboard->solvedFirst($team1, $contestProblem));
static::assertFalse($scoreboard->solvedFirst($team2, $contestProblem));

// Now create a rejudging: it will apply a new judging for the submission of $team2 that is correct
// Now create a rejudging: it will apply a new fake judging for the submission of $team2 that is correct
$rejudging = (new Rejudging())
->setStarttime(Utils::now())
->setReason(__METHOD__);
Expand All @@ -72,9 +70,12 @@ public function testUpdateFirstToSolve(): void
// Now apply the rejudging
$rejudgingService->finishRejudging($rejudging, RejudgingService::ACTION_APPLY);

// Finally, get the scoreboard again and test if the first to solve changed
$scoreboard = $scoreboardService->getScoreboard($contest, true);
// Retrieve the scoreboard again.
// Note that there is no manual scoreboard refresh necessary here as the rejudging service does all
// necessary updates.
$scoreboard = $scoreboardService->getScoreboard($contest, jury: true);

// Now both teams solved the problem, but $team2 solved it first.
static::assertFalse($scoreboard->solvedFirst($team1, $contestProblem));
static::assertTrue($scoreboard->solvedFirst($team2, $contestProblem));
}
Expand Down
Loading