/** * Creates a run to the given problem * * @param type $problemData * @param type $contestant */ public static function createRunToProblem($problemData, $contestant) { $r = self::createRequestCommon($problemData, null, $contestant); // Call API RunController::$grader = new GraderMock(); $response = RunController::apiCreate($r); // Clean up unset($_REQUEST); return array('request' => $r, 'contestant' => $contestant, 'response' => $response); }
/** * User should wait between consecutive runs. * * @expectedException NotAllowedToSubmitException */ public function testRunsToPublicProblemInsideSubmissionGap() { $originalGap = RunController::$defaultSubmissionGap; RunController::$defaultSubmissionGap = 60; try { // Create public problem $problemData = ProblemsFactory::createProblem(); // Create our contestant $this->contestant = UserFactory::createUser(); // Create an empty request $r = new Request(); // Log in as contest director $r["auth_token"] = $this->login($this->contestant); // Build request $r["contest_alias"] = ""; // Not inside a contest $r["problem_alias"] = $problemData["request"]["alias"]; $r["language"] = "c"; $r["source"] = "#include <stdio.h>\nint main() { printf(\"3\"); return 0; }"; //PHPUnit does not set IP address, doing it manually $_SERVER["REMOTE_ADDR"] = "127.0.0.1"; // Call API $this->detourGraderCalls($this->exactly(1)); $response = RunController::apiCreate($r); // Validate the run $this->assertRun($r, $response); // Call API $response = RunController::apiCreate($r); } finally { RunController::$defaultSubmissionGap = $originalGap; } }
/** * User should wait between consecutive runs. * * @expectedException NotAllowedToSubmitException */ public function testRunsToPublicProblemInsideSubmissionGap() { $originalGap = RunController::$defaultSubmissionGap; RunController::$defaultSubmissionGap = 60; try { // Create public problem $problemData = ProblemsFactory::createProblem(); // Create our contestant $this->contestant = UserFactory::createUser(); // Create an empty request $r = new Request(); // Log in as contest director $r['auth_token'] = $this->login($this->contestant); // Build request $r['contest_alias'] = ''; // Not inside a contest $r['problem_alias'] = $problemData['request']['alias']; $r['language'] = 'c'; $r['source'] = "#include <stdio.h>\nint main() { printf(\"3\"); return 0; }"; // Call API $this->detourGraderCalls($this->exactly(1)); $response = RunController::apiCreate($r); // Validate the run $this->assertRun($r, $response); // Call API $response = RunController::apiCreate($r); } finally { RunController::$defaultSubmissionGap = $originalGap; } }