/** * 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; } }
// Load test utils require_once OMEGAUP_ROOT . "/tests/controllers/OmegaupTestCase.php"; require_once OMEGAUP_ROOT . "/tests/common/Utils.php"; // Load Factories require_once OMEGAUP_ROOT . '/tests/factories/ProblemsFactory.php'; require_once OMEGAUP_ROOT . '/tests/factories/ContestsFactory.php'; require_once OMEGAUP_ROOT . '/tests/factories/ClarificationsFactory.php'; require_once OMEGAUP_ROOT . '/tests/factories/UserFactory.php'; require_once OMEGAUP_ROOT . '/tests/factories/RunsFactory.php'; require_once OMEGAUP_ROOT . '/tests/factories/GroupsFactory.php'; // Clean previous log Utils::CleanLog(); // Clean problems and runs path Utils::CleanPath(PROBLEMS_PATH); Utils::CleanPath(PROBLEMS_GIT_PATH); Utils::CleanPath(RUNS_PATH); Utils::CleanPath(GRADE_PATH); Utils::CleanPath(IMAGES_PATH); for ($i = 0; $i < 256; $i++) { mkdir(RUNS_PATH . sprintf('/%02x', $i), 0775, true); mkdir(GRADE_PATH . sprintf('/%02x', $i), 0775, true); } // Clean DB Utils::CleanupDB(); // Create a test default user for manual UI operations UserController::$sendEmailOnVerify = false; UserFactory::createUser("test", "testtesttest"); UserController::$sendEmailOnVerify = true; // Globally disable run wait gap. RunController::$defaultSubmissionGap = 0;
/** * 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; } }