本文整理汇总了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'));
}