本文整理匯總了PHP中AuthManager::singleton方法的典型用法代碼示例。如果您正苦於以下問題:PHP AuthManager::singleton方法的具體用法?PHP AuthManager::singleton怎麽用?PHP AuthManager::singleton使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類AuthManager
的用法示例。
在下文中一共展示了AuthManager::singleton方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testAbstractAuthenticationProvider
public function testAbstractAuthenticationProvider()
{
$provider = $this->getMockForAbstractClass(AbstractAuthenticationProvider::class);
$providerPriv = \TestingAccessWrapper::newFromObject($provider);
$obj = $this->getMockForAbstractClass('Psr\\Log\\LoggerInterface');
$provider->setLogger($obj);
$this->assertSame($obj, $providerPriv->logger, 'setLogger');
$obj = AuthManager::singleton();
$provider->setManager($obj);
$this->assertSame($obj, $providerPriv->manager, 'setManager');
$obj = $this->getMockForAbstractClass('Config');
$provider->setConfig($obj);
$this->assertSame($obj, $providerPriv->config, 'setConfig');
$this->assertType('string', $provider->getUniqueId(), 'getUniqueId');
}
示例2: testPostAuthentication
public function testPostAuthentication()
{
$provider = new ThrottlePreAuthenticationProvider(['passwordAttemptThrottle' => [], 'cache' => new \HashBagOStuff()]);
$provider->setLogger(new \TestLogger());
$provider->setConfig(new \HashConfig(['AccountCreationThrottle' => null, 'PasswordAttemptThrottle' => null]));
$provider->setManager(AuthManager::singleton());
$provider->postAuthentication(\User::newFromName('SomeUser'), AuthenticationResponse::newPass());
$provider = new ThrottlePreAuthenticationProvider(['passwordAttemptThrottle' => [['count' => 2, 'seconds' => 86400]], 'cache' => new \HashBagOStuff()]);
$logger = new \TestLogger(true);
$provider->setLogger($logger);
$provider->setConfig(new \HashConfig(['AccountCreationThrottle' => null, 'PasswordAttemptThrottle' => null]));
$provider->setManager(AuthManager::singleton());
$provider->postAuthentication(\User::newFromName('SomeUser'), AuthenticationResponse::newPass());
$this->assertSame([[\Psr\Log\LogLevel::ERROR, 'throttler data not found for {user}']], $logger->getBuffer());
}
示例3: testRangeBlock
public function testRangeBlock()
{
$blockOptions = ['address' => '127.0.0.0/24', 'reason' => __METHOD__, 'expiry' => time() + 100500, 'createAccount' => true];
$block = new \Block($blockOptions);
$block->insert();
$scopeVariable = new \Wikimedia\ScopedCallback([$block, 'delete']);
$user = \User::newFromName('UTNormalUser');
if ($user->getID() == 0) {
$user->addToDatabase();
\TestUser::setPasswordForUser($user, 'UTNormalUserPassword');
$user->saveSettings();
}
$this->setMwGlobals(['wgUser' => $user]);
$newuser = \User::newFromName('RandomUser');
$provider = new CheckBlocksSecondaryAuthenticationProvider(['blockDisablesLogin' => true]);
$provider->setLogger(new \Psr\Log\NullLogger());
$provider->setConfig(new \HashConfig());
$provider->setManager(AuthManager::singleton());
$ret = $provider->beginSecondaryAuthentication($user, []);
$this->assertEquals(AuthenticationResponse::FAIL, $ret->status);
$status = $provider->testUserForCreation($newuser, AuthManager::AUTOCREATE_SOURCE_SESSION);
$this->assertInstanceOf('StatusValue', $status);
$this->assertFalse($status->isOK());
$this->assertTrue($status->hasMessage('cantcreateaccount-range-text'));
$status = $provider->testUserForCreation($newuser, false);
$this->assertInstanceOf('StatusValue', $status);
$this->assertFalse($status->isOK());
$this->assertTrue($status->hasMessage('cantcreateaccount-range-text'));
}