当前位置: 首页>>代码示例>>PHP>>正文


PHP UserFactory::createUser方法代码示例

本文整理汇总了PHP中UserFactory::createUser方法的典型用法代码示例。如果您正苦于以下问题:PHP UserFactory::createUser方法的具体用法?PHP UserFactory::createUser怎么用?PHP UserFactory::createUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserFactory的用法示例。


在下文中一共展示了UserFactory::createUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testRemoveUser

 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']));
 }
开发者ID:andreasantillana,项目名称:omegaup,代码行数:27,代码来源:ContestRemoveUserTest.php

示例2: getRequest

 /**
  * 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);
 }
开发者ID:kukogit,项目名称:omegaup,代码行数:43,代码来源:ProblemsFactory.php

示例3: testGetStatsNoWaitTime

 /**
  * 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']);
 }
开发者ID:andreasantillana,项目名称:omegaup,代码行数:31,代码来源:ContestStatsTest.php

示例4: testContestUsersValid

 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"]));
 }
开发者ID:kukogit,项目名称:omegaup,代码行数:28,代码来源:ContestUsersTest.php

示例5: testGetRunsForContest

 /**
  * 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"]);
 }
开发者ID:kukogit,项目名称:omegaup,代码行数:29,代码来源:ContestRunsTest.php

示例6: testCreateValidClarification

 /**
  * 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());
 }
开发者ID:kukogit,项目名称:omegaup,代码行数:30,代码来源:ClarificationCreateTest.php

示例7: testUserUpdate

 /**
  * 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"]));
 }
开发者ID:kukogit,项目名称:omegaup,代码行数:28,代码来源:UserUpdateTest.php

示例8: getRequest

 /**
  * 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);
 }
开发者ID:kukogit,项目名称:omegaup,代码行数:36,代码来源:ContestsFactory.php

示例9: getRequest

 /**
  * 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);
 }
开发者ID:RicardoMelgoza,项目名称:omegaup,代码行数:38,代码来源:ContestsFactory.php

示例10: testSimpleRegistrationActions

 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);
 }
开发者ID:heduenas,项目名称:omegaup,代码行数:59,代码来源:RegisterToContestTest.php

示例11: testCoderOfTheMonthList

 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']));
 }
开发者ID:andreasantillana,项目名称:omegaup,代码行数:8,代码来源:CoderOfTheMonthTest.php

示例12: prepareArticle

 /**
  * Prepares and returns an article
  *
  * @param User $user
  * @param str $title
  * @param int $count
  *
  * @return Article
  */
 public function prepareArticle(User $user = null, $title = null, $count = 1)
 {
     if (!$user) {
         $user = $this->userFactory->createUser();
     }
     $article = $this->articleFactory->createArticle($user, $title, $count);
     return $article;
 }
开发者ID:TiagoMaiaL,项目名称:wiki,代码行数:17,代码来源:ScenarioService.php

示例13: testNoProblems

 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"]));
 }
开发者ID:kukogit,项目名称:omegaup,代码行数:9,代码来源:UserProblemsTest.php

示例14: testBadUserUpdate

 /**
  * @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);
 }
开发者ID:andreasantillana,项目名称:omegaup,代码行数:13,代码来源:UserUpdateTest.php

示例15: testUserRankByProblemsSolvedWith0Runs

 /**
  * 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);
 }
开发者ID:RicardoMelgoza,项目名称:omegaup,代码行数:13,代码来源:UserRankTest.php


注:本文中的UserFactory::createUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。