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


PHP UserFactory::createAdminUser方法代码示例

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


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

示例1: refreshUserRank

 private function refreshUserRank()
 {
     $r = new Request();
     $admin = UserFactory::createAdminUser();
     $r['auth_token'] = $this->login($admin);
     UserController::apiRefreshUserRank($r);
 }
开发者ID:andreasantillana,项目名称:omegaup,代码行数:7,代码来源:UserRankTest.php

示例2: testCreateUserPositive

 /**
  * Reset password via admin
  */
 public function testCreateUserPositive()
 {
     // Create an user in omegaup
     $user = UserFactory::createUser();
     // Create the admin who will change the password
     $admin = UserFactory::createAdminUser();
     $r = new Request();
     $r["auth_token"] = $this->login($admin);
     $r["username"] = $user->getUsername();
     $r["password"] = Utils::CreateRandomString();
     // Call api
     UserController::apiChangePassword($r);
     // Try to login with old password, should fail
     try {
         $this->login($user);
         $this->fail("Reset password failed");
     } catch (Exception $e) {
         // We are OK
     }
     // Set new password and try again, should succeed
     $user->setPassword($r["password"]);
     $this->login($user);
     // Sanity check, admin should be able to login fine
     $this->login($admin);
 }
开发者ID:kukogit,项目名称:omegaup,代码行数:28,代码来源:UserResetPasswordTest.php

示例3: testListWithAliasQuery

 /**
  * Test List API with query param
  */
 public function testListWithAliasQuery()
 {
     $problemDataPublic = ProblemsFactory::createProblem(null, null, 1);
     $problemDataPrivate = ProblemsFactory::createProblem(null, null, 0);
     $user = UserFactory::createUser();
     $admin = UserFactory::createAdminUser();
     // Expect public problem only
     $r = new Request();
     $r["auth_token"] = $this->login($user);
     $r["query"] = substr($problemDataPublic["request"]["title"], 2, 5);
     $response = ProblemController::apiList($r);
     $this->assertArrayContainsInKey($response["results"], "alias", $problemDataPublic["request"]["alias"]);
     // Expect 0 problems, matches are private for $user
     $r = new Request();
     $r["auth_token"] = $this->login($user);
     $r["query"] = substr($problemDataPrivate["request"]["title"], 2, 5);
     $response = ProblemController::apiList($r);
     $this->assertEquals(0, count($response["results"]));
     // Expect 1 problem, admin can see private problem
     $r = new Request();
     $r["auth_token"] = $this->login($admin);
     $r["query"] = substr($problemDataPrivate["request"]["title"], 2, 5);
     $response = ProblemController::apiList($r);
     $this->assertArrayContainsInKey($response["results"], "alias", $problemDataPrivate["request"]["alias"]);
     // Expect public problem only
     $r = new Request();
     $r["auth_token"] = $this->login($user);
     $response = ProblemController::apiList($r);
     $this->assertArrayContainsInKey($response["results"], "alias", $problemDataPublic["request"]["alias"]);
 }
开发者ID:kukogit,项目名称:omegaup,代码行数:33,代码来源:ProblemListTest.php

示例4: testUsernameVerificationByAdminInvalidUsername

 /**
  * Admin can verify users only with username
  * Testing invalid username
  *
  * @expectedException NotFoundException
  */
 public function testUsernameVerificationByAdminInvalidUsername()
 {
     // Admin will verify $user
     $admin = UserFactory::createAdminUser();
     // Call api using admin
     $response = UserController::apiVerifyEmail(new Request(array('auth_token' => $this->login($admin), 'usernameOrEmail' => Utils::CreateRandomString())));
 }
开发者ID:andreasantillana,项目名称:omegaup,代码行数:13,代码来源:UserCreateTest.php

示例5: testPrivateContestForSystemAdmin

 /** 
  * 
  */
 public function testPrivateContestForSystemAdmin()
 {
     $r = new Request();
     // Create new private contest
     $contestData = ContestsFactory::createContest(null, false);
     $r["auth_token"] = $this->login(UserFactory::createAdminUser());
     $response = ContestController::apiList($r);
     // Assert our contest is there
     $this->assertTitleInList($response, $contestData);
 }
开发者ID:kukogit,项目名称:omegaup,代码行数:13,代码来源:ContestListTest.php

示例6: testRecommendedShowsOnTop

 /**
  * Test that contests with recommended flag show first in list.
  */
 public function testRecommendedShowsOnTop()
 {
     $r = new Request();
     // Create 2 contests, with the not-recommended.finish_time > recommended.finish_time
     $recommendedContestData = ContestsFactory::createContest();
     $notRecommendedContestData = ContestsFactory::createContest(null, 0, null, $recommendedContestData['request']['finish_time'] + 1);
     // Get a user for our scenario
     $contestant = UserFactory::createUser();
     // Turn recommended ON
     $r = new Request();
     $r['contest_alias'] = $recommendedContestData['request']['alias'];
     $r['auth_token'] = $this->login(UserFactory::createAdminUser());
     $r['value'] = 1;
     ContestController::apiSetRecommended($r);
     // Get list of contests
     $r['auth_token'] = $this->login($contestant);
     $response = ContestController::apiList($r);
     // Check that recommended contest is earlier in list han not-recommended
     $recommendedPosition = 0;
     $notRecommendedPosition = 0;
     foreach ($response['results'] as $contest) {
         if ($contest['title'] == $recommendedContestData['request']['title']) {
             break;
         }
         $recommendedPosition++;
     }
     foreach ($response['results'] as $contest) {
         if ($contest['title'] == $notRecommendedContestData['request']['title']) {
             break;
         }
         $notRecommendedPosition++;
     }
     $this->assertTrue($recommendedPosition < $notRecommendedPosition);
 }
开发者ID:RicardoMelgoza,项目名称:omegaup,代码行数:37,代码来源:ContestListTest.php

示例7: testSetRecommendedFlag

 /**
  * Set Recommended flag to a given contest
  */
 public function testSetRecommendedFlag()
 {
     // Get a contest
     $contestData = ContestsFactory::createContest();
     // Prepare request
     $r = new Request();
     $r['contest_alias'] = $contestData['request']['alias'];
     // Log in with site admin
     $r['auth_token'] = $this->login(UserFactory::createAdminUser());
     // Update value to TRUE
     $r['value'] = 1;
     // Call API
     ContestController::apiSetRecommended($r);
     // Verify setting
     $contestData['request']['recommended'] = $r['value'];
     $this->assertContest($contestData['request']);
     // Turn flag down
     $r['value'] = 0;
     // Call API again
     ContestController::apiSetRecommended($r);
     // Verify setting
     $contestData['request']['recommended'] = $r['value'];
     $this->assertContest($contestData['request']);
 }
开发者ID:andreasantillana,项目名称:omegaup,代码行数:27,代码来源:ContestUpdateTest.php


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