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


PHP AuthManager::singleton方法代码示例

本文整理汇总了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');
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:15,代码来源:AbstractAuthenticationProviderTest.php

示例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());
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:15,代码来源:ThrottlePreAuthenticationProviderTest.php

示例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'));
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:29,代码来源:CheckBlocksSecondaryAuthenticationProviderTest.php


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