public function testProblemArenaAndSubmbit() { // Login $contestant = $this->createUserAndLogin(); // Create a problem $problemData = ProblemsFactory::createProblem(); // Click in Problems $this->clickAndWait('link=Problemas'); // Click in Problem $problemData $this->waitForElementPresent('//*[@id="problems_list"]/table/tbody/tr[2]/td/a'); $this->clickAndWait('link=' . $problemData['request']['title']); // Check that arena contains the title $this->waitForElementPresent('//*[@id="problem"]/h1'); $this->assertElementContainsText('//*[@id="problem"]/h1', $problemData['request']['title']); // Click in New run $this->click('link=Nuevo envío'); $this->waitForElementPresent('//*[@id="lang-select"]'); // Write some code and submit $this->select('name=language', 'label=C++'); $this->type('code', 'Code lol'); $this->click('//*[@id="submit"]/input'); // Get run ID sleep(1); $runs = ProblemController::apiRuns(new Request(array('problem_alias' => $problemData['request']['alias'], 'auth_token' => OmegaupTestCase::login($contestant)))); // Wait for submit history to show $this->waitForElementPresent('//*[@id="run_' . $runs['runs'][0]['guid'] . '"]/td[2]'); }
/** * Answer a clarification * * @param type $clarificationData * @param type $contestData * @param type $message */ public static function answer($clarificationData, $contestData, $message = 'lol') { // Prepare request $r = new Request(); $r["clarification_id"] = $clarificationData["response"]["clarification_id"]; // Log in the user $r["auth_token"] = OmegaupTestCase::login($contestData["director"]); // Update answer $r["answer"] = $message; // Call api ClarificationController::apiUpdate($r); }
/** * Builds and returns a request object to be used for RunController::apiCreate * * @param type $problemData * @param type $contestData * @param type $contestant * @return Request */ private static function createRequestCommon($problemData, $contestData, $contestant) { // Create an empty request $r = new Request(); // Log in as contestant $r['auth_token'] = OmegaupTestCase::login($contestant); // Build request if (!is_null($contestData)) { $r['contest_alias'] = $contestData['request']['alias']; } $r['problem_alias'] = $problemData['request']['alias']; $r['language'] = 'c'; $r['source'] = "#include <stdio.h>\nint main() { printf(\"3\"); return 0; }"; return $r; }
/** * Builds and returns a request object to be used for RunController::apiCreate * * @param type $problemData * @param type $contestData * @param type $contestant * @return Request */ private static function createRequestCommon($problemData, $contestData, $contestant) { // Create an empty request $r = new Request(); // Log in as contestant $r["auth_token"] = OmegaupTestCase::login($contestant); // Build request if (!is_null($contestData)) { $r["contest_alias"] = $contestData["request"]["alias"]; } $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"; return $r; }
public static function addAdminUser($contestData, $user) { // Prepare our request $r = new Request(); $r['contest_alias'] = $contestData['request']['alias']; $r['usernameOrEmail'] = $user->getUsername(); // Log in the contest director $r['auth_token'] = OmegaupTestCase::login($contestData['director']); // Call api ContestController::apiAddAdmin($r); unset($_REQUEST); }
/** * Adds contest to scoreboard helper * * @param array $contestData * @param array $scorebaordData * @param array $groupData */ public static function addContestToScoreboard($contestData, $scoreboardData, $groupData, $onlyAC = 0, $weight = 1) { GroupScoreboardController::apiAddContest(new Request(array("auth_token" => OmegaupTestCase::login($groupData["owner"]), "group_alias" => $groupData["request"]["alias"], "scoreboard_alias" => $scoreboardData["request"]["alias"], "contest_alias" => $contestData["request"]["alias"], "only_ac" => $onlyAC, "weight" => $weight))); }
public static function addAdminUser($contestData, $user) { // Prepare our request $r = new Request(); $r["contest_alias"] = $contestData["request"]["alias"]; $r["usernameOrEmail"] = $user->getUsername(); // Log in the contest director $r["auth_token"] = OmegaupTestCase::login($contestData["director"]); // Call api ContestController::apiAddAdmin($r); unset($_REQUEST); }
/** * */ public static function createProblem($zipName = null, $title = null, $public = 1, Users $author = null, $languages = null) { if (is_null($zipName)) { $zipName = OMEGAUP_RESOURCES_ROOT . 'testproblem.zip'; } // Get a user $problemData = self::getRequest($zipName, $title, $public, $author, $languages); $r = $problemData["request"]; $problemAuthor = $problemData["author"]; // Login user $r["auth_token"] = OmegaupTestCase::login($problemAuthor); // Get File Uploader Mock and tell Omegaup API to use it FileHandler::SetFileUploader(new FileUploaderMock()); // Call the API ProblemController::apiCreate($r); // Clean up our mess unset($_REQUEST); return array("request" => $r, "author" => $problemAuthor); }
/** * Adds contest to scoreboard helper * * @param array $contestData * @param array $scorebaordData * @param array $groupData */ public static function addContestToScoreboard($contestData, $scoreboardData, $groupData, $onlyAC = 0, $weight = 1) { GroupScoreboardController::apiAddContest(new Request(array('auth_token' => OmegaupTestCase::login($groupData['owner']), 'group_alias' => $groupData['request']['alias'], 'scoreboard_alias' => $scoreboardData['request']['alias'], 'contest_alias' => $contestData['request']['alias'], 'only_ac' => $onlyAC, 'weight' => $weight))); }