當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。