本文整理汇总了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);
}
示例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);
}
示例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"]);
}
示例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())));
}
示例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);
}
示例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);
}
示例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']);
}