/** * Returns a Request object with complete context to create a contest * * @param string $title * @param string $public * @param Users $contestDirector * @return Request */ public static function getRequest($title = null, $public = 0, Users $contestDirector = null, $languages = null) { if (is_null($contestDirector)) { $contestDirector = UserFactory::createUser(); } if (is_null($title)) { $title = Utils::CreateRandomString(); } // Set context $r = new Request(); $r["title"] = $title; $r["description"] = "description"; $r["start_time"] = Utils::GetPhpUnixTimestamp() - 60 * 60; $r["finish_time"] = Utils::GetPhpUnixTimestamp() + 60 * 60; $r["window_length"] = null; $r["public"] = $public; $r["alias"] = substr($title, 0, 20); $r["points_decay_factor"] = ".02"; $r["partial_score"] = "0"; $r["submissions_gap"] = "0"; $r["feedback"] = "yes"; $r["penalty"] = 100; $r["scoreboard"] = 100; $r["penalty_type"] = "contest_start"; $r["penalty_calc_policy"] = "sum"; $r['languages'] = $languages; return array("request" => $r, "director" => $contestDirector); }
function __construct($dbhost, $dbuser, $dbpswd, $dbname) { // assert that the resources we need are there if (!defined('MODELS')) { die; } // Model-specs require_once MODELS . '/UserFactory.php'; require_once MODELS . '/EmployeeFactory.php'; /* require_once 'Shifts.php'; require_once 'Schemas.php'; */ // Database $this->dbhost = $dbhost; $this->dbuser = $dbuser; $this->dbpswd = $dbpswd; $this->dbname = $dbname; mysql_connect($this->dbhost, $this->dbuser, $this->dbpswd, $this->dbname); mysql_select_db($this->dbname); // User $this->user = null; if (isset($_SESSION['user_id'])) { $this->user = UserFactory::create($_SESSION['user_id']); } elseif (isset($_COOKIE['user_id']) && isset($_COOKIE['email']) && isset($_COOKIE['password'])) { $user = UserFactory::create($_COOKIE['user_id']); if ($user->getEmail() == $_COOKIE['email'] && $user->getPassword() == $_COOKIE['password']) { $_SESSION['user_id'] = $user->getUserId(); $this->user = $user; } } }
public function testContestUsersValid() { // Get a contest $contestData = ContestsFactory::createContest(); // Create 10 users $n = 10; $users = array(); for ($i = 0; $i < $n; $i++) { // Create a user $users[$i] = UserFactory::createUser(); // Add it to the contest ContestsFactory::addUser($contestData, $users[$i]); } // Create a n+1 user who will just join to the contest withot being // added via API. For public contests, by entering to the contest, the user should be in // the list of contest's users. $nonRegisteredUser = UserFactory::createUser(); ContestsFactory::openContest($contestData, $nonRegisteredUser); // Prepare request $r = new Request(); $r["contest_alias"] = $contestData["request"]["alias"]; // Log in with the admin of the contest $r["auth_token"] = $this->login($contestData["director"]); // Call API $response = ContestController::apiUsers($r); // Check that we have n+1 users $this->assertEquals($n + 1, count($response["users"])); }
/** * Returns a Request object with valid info to create a problem and the * author of the problem * * @param string $title * @param string $zipName * @return Array */ public static function getRequest($zipName = null, $title = null, $public = 1, Users $author = null, $languages = null) { if (is_null($author)) { $author = UserFactory::createUser(); } if (is_null($title)) { $title = Utils::CreateRandomString(); } if (is_null($zipName)) { $zipName = OMEGAUP_RESOURCES_ROOT . 'testproblem.zip'; } $r = new Request(); $r["title"] = $title; $r['alias'] = substr(preg_replace('/[^a-zA-Z0-9_-]/', '', str_replace(' ', '-', $r['title'])), 0, 32); $r["author_username"] = $author->getUsername(); $r["validator"] = "token"; $r["time_limit"] = 5000; $r["overall_wall_time_limit"] = 60000; $r["validator_time_limit"] = 30000; $r["extra_wall_time"] = 0; $r["memory_limit"] = 32000; $r["source"] = "yo"; $r["order"] = "normal"; $r["public"] = $public; $r["output_limit"] = 10240; if ($languages == null) { $r["languages"] = 'c,cpp,py'; } else { $r["languages"] = $languages; } $r["stack_limit"] = 10000; // Set file upload context $_FILES['problem_contents']['tmp_name'] = $zipName; return array("request" => $r, "author" => $author, "zip_path" => $zipName); }
/** * Checks that, if there's no wait time, 0 is posted in max_wait_time */ public function testGetStatsNoWaitTime() { // Get a problem $problemData = ProblemsFactory::createProblem(); // Get a contest $contestData = ContestsFactory::createContest(); // Add the problem to the contest ContestsFactory::addProblemToContest($problemData, $contestData); // Create our contestant $contestant = UserFactory::createUser(); $ACRunsCount = 2; $ACRunsData = array(); for ($i = 0; $i < $ACRunsCount; $i++) { $ACRunsData[$i] = RunsFactory::createRun($problemData, $contestData, $contestant); // Grade the run RunsFactory::gradeRun($ACRunsData[$i]); } // Create request $r = new Request(); $r['contest_alias'] = $contestData['request']['alias']; $r['auth_token'] = $this->login($contestData['director']); // Call API $response = ContestController::apiStats($r); // Check number of pending runs $this->assertEquals($ACRunsCount, $response['total_runs']); $this->assertEquals(0, $response['max_wait_time']); $this->assertEquals(0, $response['max_wait_time_guid']); }
/** * Contestant submits runs and admin is able to get them */ public function testGetRunsForContest() { // Get a problem $problemData = ProblemsFactory::createProblem(); // Get a contest $contestData = ContestsFactory::createContest(); // Add the problem to the contest ContestsFactory::addProblemToContest($problemData, $contestData); // Create our contestant $contestant = UserFactory::createUser(); // Create a run $runData = RunsFactory::createRun($problemData, $contestData, $contestant); // Grade the run RunsFactory::gradeRun($runData); // Create request $r = new Request(); $r["contest_alias"] = $contestData["request"]["alias"]; $r["auth_token"] = $this->login($contestData["director"]); // Call API $response = ContestController::apiRuns($r); // Assert $this->assertEquals(1, count($response["runs"])); $this->assertEquals($runData["response"]["guid"], $response["runs"][0]["guid"]); $this->assertEquals($contestant->username, $response["runs"][0]["username"]); $this->assertEquals("J1", $response["runs"][0]["judged_by"]); }
public function testRemoveUser() { // Get a contest $contestData = ContestsFactory::createContest(); // Create a user $user = UserFactory::createUser(); // Add user to contest ContestsFactory::addUser($contestData, $user); // Validate 0 users $r = new Request(); $r['contest_alias'] = $contestData['request']['alias']; $r['auth_token'] = $this->login($contestData['director']); $response = ContestController::apiUsers($r); $this->assertEquals(1, count($response['users'])); // Remove user $r = new Request(); $r['contest_alias'] = $contestData['request']['alias']; $r['usernameOrEmail'] = $user->getUsername(); $r['auth_token'] = $this->login($contestData['director']); ContestController::apiRemoveUser($r); // Validate 0 users in contest $r = new Request(); $r['contest_alias'] = $contestData['request']['alias']; $r['auth_token'] = $this->login($contestData['director']); $response = ContestController::apiUsers($r); $this->assertEquals(0, count($response['users'])); }
/** * Contestant submits runs and admin is able to get them */ public function testGetRunsForContest() { // Get a problem $problemData = ProblemsFactory::createProblem(); // Get a contest $contestData = ContestsFactory::createContest(); // Add the problem to the contest ContestsFactory::addProblemToContest($problemData, $contestData); // Create our contestant $contestant = UserFactory::createUser(); // Create a run $runData = RunsFactory::createRun($problemData, $contestData, $contestant); // Grade the run RunsFactory::gradeRun($runData); // Create request $r = new Request(); $r['contest_alias'] = $contestData['request']['alias']; $r['auth_token'] = $this->login($contestData['director']); // Call API $response = ContestController::apiRuns($r); // Assert $this->assertEquals(1, count($response['runs'])); $this->assertEquals($runData['response']['guid'], $response['runs'][0]['guid']); $this->assertEquals($contestant->username, $response['runs'][0]['username']); $this->assertEquals('J1', $response['runs'][0]['judged_by']); }
/** * Creates a valid clarification */ public function testCreateValidClarification() { // Get a problem $problemData = ProblemsFactory::createProblem(); // Get a contest $contestData = ContestsFactory::createContest(); // Add the problem to the contest ContestsFactory::addProblemToContest($problemData, $contestData); // Create our contestant who will submit the clarification $contestant = UserFactory::createUser(); // Call the API $this->detourBroadcasterCalls(); $clarificationData = ClarificationsFactory::createClarification($problemData, $contestData, $contestant); // Assert status of new contest $this->assertArrayHasKey("clarification_id", $clarificationData['response']); // Verify that clarification was inserted in the database $clarification = ClarificationsDAO::getByPK($clarificationData['response']['clarification_id']); // Verify our retreived clarificatoin $this->assertNotNull($clarification); $this->assertEquals($clarificationData['request']['message'], $clarification->getMessage()); // We need to verify that the contest and problem IDs where properly saved // Extractiing the contest and problem from DB to check IDs $problem = ProblemsDAO::getByAlias($problemData["request"]["alias"]); $contest = ContestsDAO::getByAlias($contestData["request"]["alias"]); $this->assertEquals($contest->getContestId(), $clarification->getContestId()); $this->assertEquals($problem->getProblemId(), $clarification->getProblemId()); }
public function testLogin() { // Turn off sending email on usere creation UserController::$sendEmailOnVerify = false; // Create a user $contestant = UserFactory::createUserWithoutVerify(); // Open index $this->open('/'); // Click in Iniciar Sesion $this->clickAndWait('link=Inicia sesion'); // Type login data $this->type('user', $contestant->getUsername()); $this->type('pass', $contestant->getPassword()); // Click inicia sesion $this->clickAndWait("//input[@value='Inicia sesion']"); // Wait for message $this->waitForElementPresent('//*[@id="content"]/div[2]/div'); $this->assertElementContainsText('//*[@id="content"]/div[2]/div', 'Your email is not verified yet. Please check your e-mail.'); // Go to verification page and wait for redirection to login page $this->open('/api/user/verifyemail/id/' . $contestant->getVerificationId()); $this->waitForElementPresent('//*[@id="content"]/div[2]/div[1]/h1'); // Type login data $this->type('user', $contestant->getUsername()); $this->type('pass', $contestant->getPassword()); // Click inicia sesion $this->clickAndWait("//input[@value='Inicia sesion']"); // Sanity check that we are logged in $this->waitForElementPresent('//*[@id="wrapper"]/div[1]/a'); $this->assertElementContainsText('//*[@id="wrapper"]/div[1]/a', $contestant->getUsername()); }
public static function instance() { if (!isset(self::$singleton)) { self::$singleton = new UserFactory(); } return self::$singleton; }
/** * Basic update test */ public function testUserUpdate() { // Create the user to edit $user = UserFactory::createUser(); $r = new Request(); // Login $r["auth_token"] = $this->login($user); // Change values $r["name"] = Utils::CreateRandomString(); $r["country_id"] = 'MX'; $r["state_id"] = 3; $r["scholar_degree"] = 'Maestría'; $r["birth_date"] = strtotime('1988-01-01'); $r["graduation_date"] = strtotime('2016-02-02'); // Call api $response = UserController::apiUpdate($r); // Check user from db $user_db = AuthTokensDAO::getUserByToken($r["auth_token"]); $this->assertEquals($user_db->getName(), $r["name"]); $this->assertEquals($user_db->getCountryId(), $r["country_id"]); $this->assertEquals($user_db->getStateId(), $r["state_id"]); $this->assertEquals($user_db->getScholarDegree(), $r["scholar_degree"]); $this->assertEquals($user_db->getBirthDate(), gmdate('Y-m-d', $r["birth_date"])); $this->assertEquals($user_db->getGraduationDate(), gmdate('Y-m-d', $r["graduation_date"])); }
/** * Returns a Request object with complete context to create a contest * * @param string $title * @param string $public * @param Users $contestDirector * @return Request */ public static function getRequest($title = null, $public = 0, Users $contestDirector = null, $languages = null, $finish_time = null) { if (is_null($contestDirector)) { $contestDirector = UserFactory::createUser(); } if (is_null($title)) { $title = Utils::CreateRandomString(); } // Set context $r = new Request(); $r['title'] = $title; $r['description'] = 'description'; $r['start_time'] = Utils::GetPhpUnixTimestamp() - 60 * 60; $r['finish_time'] = $finish_time == null ? Utils::GetPhpUnixTimestamp() + 60 * 60 : $finish_time; $r['window_length'] = null; $r['public'] = $public; $r['alias'] = substr($title, 0, 20); $r['points_decay_factor'] = '.02'; $r['partial_score'] = '0'; $r['submissions_gap'] = '0'; $r['feedback'] = 'yes'; $r['penalty'] = 100; $r['scoreboard'] = 100; $r['penalty_type'] = 'contest_start'; $r['penalty_calc_policy'] = 'sum'; $r['languages'] = $languages; $r['recommended'] = 0; // This is just a default value, it is not honored by apiCreate. return array('request' => $r, 'director' => $contestDirector); }
public function testSimpleRegistrationActions() { self::log("Started"); //create a contest and its admin $contestData = ContestsFactory::createContest(null, 1); $contestAdmin = UserFactory::createUser(); ContestsFactory::addAdminUser($contestData, $contestAdmin); //make it "registrable" self::log("Udate contest to make it registrable"); $r1 = new Request(); $r1["contest_alias"] = $contestData["request"]["alias"]; $r1["contestant_must_register"] = true; $r1["auth_token"] = $this->login($contestAdmin); ContestController::apiUpdate($r1); //some user asks for contest $contestant = UserFactory::createUser(); $r2 = new Request(); $r2["contest_alias"] = $contestData["request"]["alias"]; $r2["auth_token"] = $this->login($contestant); try { $response = ContestController::apiDetails($r2); $this->AssertFalse(true, "User gained access to contest even though its registration needed."); } catch (ForbiddenAccessException $fae) { // Expected. Continue. } self::log("user registers, into contest"); ContestController::apiRegisterForContest($r2); //admin lists registrations $r3 = new Request(); $r3["contest_alias"] = $contestData["request"]["alias"]; $r3["auth_token"] = $this->login($contestAdmin); $result = ContestController::apiRequests($r3); $this->assertEquals(sizeof($result["users"]), 1); self::log("amin rejects registration"); $r3["username"] = $contestant->username; $r3["resolution"] = false; ContestController::apiArbitrateRequest($r3); //ask for details again, this should fail again $r2 = new Request(); $r2["contest_alias"] = $contestData["request"]["alias"]; $r2["auth_token"] = $this->login($contestant); try { $response = ContestController::apiDetails($r2); $this->AssertFalse(true); } catch (ForbiddenAccessException $fae) { // Expected. Continue. } //admin admits user $r3["username"] = $contestant->username; $r3["resolution"] = true; ContestController::apiArbitrateRequest($r3); //user can now submit to contest $r2 = new Request(); $r2["contest_alias"] = $contestData["request"]["alias"]; $r2["auth_token"] = $this->login($contestant); // Explicitly join contest ContestController::apiOpen($r2); ContestController::apiDetails($r2); }
public static function getInstance() { if (!isset(self::$instance)) { $class = __CLASS__; self::$instance = new $class(); } return self::$instance; }
public function testCoderOfTheMonthList() { $user = UserFactory::createUser(); $auth_token = $this->login($user); $r = new Request(array('auth_token' => $auth_token)); $response = UserController::apiCoderOfTheMonthList($r); $this->assertEquals(1, count($response['coders'])); }
function getByCompanyId($company_id, $where = NULL, $order = NULL) { if ($company_id == '') { return FALSE; } $uf = new UserFactory(); $ph = array('company_id' => $company_id); $query = ' select a.* from ' . $this->getTable() . ' as a LEFT JOIN ' . $uf->getTable() . ' as uf ON a.user_id = uf.id where uf.company_id = ? AND ( uf.deleted = 0 )'; $query .= $this->getWhereSQL($where); $query .= $this->getSortSQL($order); $this->ExecuteSQL($query, $ph); return $this; }
public function testNoProblems() { $author = UserFactory::createUser(); // Call API // Call api $r = new Request(array("auth_token" => self::login($author))); $response = UserController::apiProblems($r); $this->assertEquals(0, count($response["problems"])); }
/** * Tests apiRankByProblemsSolved for a specific user with no runs */ public function testUserRankByProblemsSolvedWith0Runs() { // Create a user and sumbit a run with him $contestant = UserFactory::createUser(); // Call API $response = UserController::apiRankByProblemsSolved(new Request(array('username' => $contestant->getUsername()))); $this->assertEquals($response['name'], $contestant->getName()); $this->assertEquals($response['problems_solved'], 0); $this->assertEquals($response['rank'], 0); }
/** * @expectedException InvalidDatabaseOperationException */ public function testBadUserUpdate() { $user = UserFactory::createUser(); $r = new Request(); $r['auth_token'] = $this->login($user); $r['name'] = Utils::CreateRandomString(); // Invalid state_id $r['state_id'] = -1; UserController::apiUpdate($r); }
/** * @test */ public function ユーザーエンティティを生成する() { $factory = new UserFactory(); $entity = $factory->entity(json_decode('{ "account_id": 123, "room_id": 322, "name": "John Smith", "chatwork_id": "tarochatworkid", "organization_id": 101, "organization_name": "Hello Company", "department": "Marketing", "title": "CMO", "url": "http://mycompany.com", "introduction": "Self Introduction", "mail": "*****@*****.**", "tel_organization": "XXX-XXXX-XXXX", "tel_extension": "YYY-YYYY-YYYY", "tel_mobile": "ZZZ-ZZZZ-ZZZZ", "skype": "myskype_id", "facebook": "myfacebook_id", "twitter": "mytwitter_id", "avatar_image_url": "https://example.com/abc.png" }', true)); $this->assertEquals(123, $entity->accountId); $this->assertEquals(322, $entity->roomId); $this->assertEquals('John Smith', $entity->name); $this->assertEquals('tarochatworkid', $entity->chatworkId); $this->assertEquals(101, $entity->organizationId); $this->assertEquals('Hello Company', $entity->organizationName); $this->assertEquals('Marketing', $entity->department); $this->assertEquals('CMO', $entity->title); $this->assertEquals('http://mycompany.com', $entity->url); $this->assertEquals('Self Introduction', $entity->introduction); $this->assertEquals('*****@*****.**', $entity->mail); $this->assertEquals('XXX-XXXX-XXXX', $entity->telOrganization); $this->assertEquals('YYY-YYYY-YYYY', $entity->telExtension); $this->assertEquals('ZZZ-ZZZZ-ZZZZ', $entity->telMobile); $this->assertEquals('myskype_id', $entity->skype); $this->assertEquals('myfacebook_id', $entity->facebook); $this->assertEquals('mytwitter_id', $entity->twitter); $this->assertEquals('https://example.com/abc.png', $entity->avatarImageUrl); }
function Login() { if (isset($_POST['submit'])) { if ($user = UserFactory::login($_POST['email'], md5($_POST['password']))) { setcookie('user_id', $user->getUserId(), time() + 3600, '/'); setcookie('email', $user->getEmail(), time() + 3600, '/'); setcookie('password', $user->getPassword(), time() + 3600, '/'); header('location: /Welcome/'); } } $this->views->flush('body', 'login'); }
public function handle_input(&$request) { $vd = new ViewDescriptor(); $vd->setPagina($request['page']); // $this->setImpToken($vd, $request); //utente non autentificato if (!$this->loggedIn()) { $this->showLoginPage($vd); } else { $user = UserFactory::instance()->cercaUtentePerId($_SESSION[BaseController::user], $_SESSION[BaseController::role]); if (isset($request["subpage"])) { switch ($request["subpage"]) { case 'gestione_ordini': $ordini = OrdineFactory::instance()->getListaOrdiniAttivi(); $vd->setSottoPagina('gestione_ordini'); break; default: $vd->setSottoPagina('home'); break; } } if (isset($request["cmd"])) { switch ($request["cmd"]) { case 'logout': $this->logout($vd); break; case 'invia': $msg = array(); $ordini = OrdineFactory::instance()->getListaOrdiniAttivi(); if (isset($request['id'])) { if (OrdineFactory::instance()->chiudiOrdinePerId($request['id']) != 1) { $msg[] = '<li>L\'ordine #' . $request['id'] . ' non è valido</li>'; } } $this->creaFeedbackUtente($msg, $vd, 'Ordine #' . $request['id'] . ' inviato'); $vd->setSottoPagina('gestione_ordini'); $this->showHomeAdmin($vd); /* Non mostra il msg di errore/conferma */ header('Location: ' . Settings::getApplicationPath() . 'php/admin/gestione_ordini'); exit; /* ************************************ */ break; default: $this->showHomeAdmin($vd); } } else { // nessun comando $user = UserFactory::instance()->cercaUtentePerId($_SESSION[BaseController::user], $_SESSION[BaseController::role]); $this->showHomeUser($vd); } } require basename(__DIR__) . '/../view/master.php'; }
/** * Reset my password * * @expectedException InvalidParameterException */ public function testResetMyPasswordBadOldPassword() { // Create an user in omegaup $user = UserFactory::createUser(); $r = new Request(); $r["auth_token"] = $this->login($user); $r["username"] = $user->getUsername(); $r["password"] = Utils::CreateRandomString(); $r["old_password"] = "******"; // Call api UserController::apiChangePassword($r); }
/** * */ public function testCreateSchoolDuplicatedName() { $user = UserFactory::createUser(); $r = new Request(array('auth_token' => $this->login($user), 'name' => Utils::CreateRandomString())); // Call api $response = SchoolController::apiCreate($r); $this->assertEquals('ok', $response['status']); $this->assertEquals(1, count(SchoolsDAO::findByName($r['name']))); // Call api again $response = SchoolController::apiCreate($r); $this->assertEquals('ok', $response['status']); $this->assertEquals(1, count(SchoolsDAO::findByName($r['name']))); }
/** * * @expectedException ForbiddenAccessException */ public function testUpdateContestNonDirector() { // Get a contest $contestData = ContestsFactory::createContest(); // Prepare request $r = new Request(); $r["contest_alias"] = $contestData["request"]["alias"]; // Log in with contest director $r["auth_token"] = $this->login(UserFactory::createUser()); // Update title $r["title"] = Utils::CreateRandomString(); // Call API ContestController::apiUpdate($r); }
public function testContestActivityReport() { // Get a contest $contestData = ContestsFactory::createContest(); $user = UserFactory::createUser(); ContestsFactory::openContest($contestData, $user); ContestController::apiDetails(new Request(array('contest_alias' => $contestData['request']['alias'], 'auth_token' => $this->login($user)))); // Call API $response = ContestController::apiActivityReport(new Request(array('contest_alias' => $contestData['request']['alias'], 'auth_token' => $this->login($contestData['director'])))); // Check that we have entries in the log. $this->assertEquals(1, count($response['events'])); $this->assertEquals($user->username, $response['events'][0]['username']); $this->assertEquals(0, $response['events'][0]['ip']); $this->assertEquals('open', $response['events'][0]['event']['name']); }
function getUniqueCountryByCompanyId($id, $where = NULL, $order = NULL) { if ($id == '') { return FALSE; } $uf = new UserFactory(); $ph = array('id' => $id); $query = ' select distinct a.country from ' . $uf->getTable() . ' as a where a.company_id = ? AND ( a.deleted = 0 )'; $query .= $this->getWhereSQL($where); $query .= $this->getSortSQL($order); return $this->db->GetCol($query, $ph); }
/** * Test apiBestScore for submits in a problem for other user */ public function testBestScoreInProblemOtherUser() { // Create problem $problemData = ProblemsFactory::createProblem(); // Create contestant $contestant = UserFactory::createUser(); // Create user who will use the API $user = UserFactory::createUser(); // Create 2 runs, 100 and 50. $runData = RunsFactory::createRunToProblem($problemData, $contestant); $runDataPA = RunsFactory::createRunToProblem($problemData, $contestant); RunsFactory::gradeRun($runData); RunsFactory::gradeRun($runDataPA, 0.5, 'PA'); // Call API $response = ProblemController::apiBestScore(new Request(array('auth_token' => $this->login($user), 'problem_alias' => $problemData['request']['alias'], 'username' => $contestant->getUsername()))); $this->assertEquals(100.0, $response['score']); }
/** * Test apiBestScore for submits in a problem for other user */ public function testBestScoreInProblemOtherUser() { // Create problem $problemData = ProblemsFactory::createProblem(); // Create contestant $contestant = UserFactory::createUser(); // Create user who will use the API $user = UserFactory::createUser(); // Create 2 runs, 100 and 50. $runData = RunsFactory::createRunToProblem($problemData, $contestant); $runDataPA = RunsFactory::createRunToProblem($problemData, $contestant); RunsFactory::gradeRun($runData); RunsFactory::gradeRun($runDataPA, 0.5, "PA"); // Call API $response = ProblemController::apiBestScore(new Request(array("auth_token" => $this->login($user), "problem_alias" => $problemData["request"]["alias"], "username" => $contestant->getUsername()))); $this->assertEquals(100.0, $response["score"]); }