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


PHP TestingAccessWrapper::getPrimaryAuthenticationProviders方法代码示例

本文整理汇总了PHP中TestingAccessWrapper::getPrimaryAuthenticationProviders方法的典型用法代码示例。如果您正苦于以下问题:PHP TestingAccessWrapper::getPrimaryAuthenticationProviders方法的具体用法?PHP TestingAccessWrapper::getPrimaryAuthenticationProviders怎么用?PHP TestingAccessWrapper::getPrimaryAuthenticationProviders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestingAccessWrapper的用法示例。


在下文中一共展示了TestingAccessWrapper::getPrimaryAuthenticationProviders方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testForcePrimaryAuthenticationProviders

 public function testForcePrimaryAuthenticationProviders()
 {
     $mockA = $this->getMockForAbstractClass(PrimaryAuthenticationProvider::class);
     $mockB = $this->getMockForAbstractClass(PrimaryAuthenticationProvider::class);
     $mockB2 = $this->getMockForAbstractClass(PrimaryAuthenticationProvider::class);
     $mockA->expects($this->any())->method('getUniqueId')->will($this->returnValue('A'));
     $mockB->expects($this->any())->method('getUniqueId')->will($this->returnValue('B'));
     $mockB2->expects($this->any())->method('getUniqueId')->will($this->returnValue('B'));
     $this->primaryauthMocks = [$mockA];
     $this->logger = new \TestLogger(true);
     // Test without first initializing the configured providers
     $this->initializeManager();
     $this->manager->forcePrimaryAuthenticationProviders([$mockB], 'testing');
     $this->assertSame(['B' => $mockB], $this->managerPriv->getPrimaryAuthenticationProviders());
     $this->assertSame(null, $this->managerPriv->getAuthenticationProvider('A'));
     $this->assertSame($mockB, $this->managerPriv->getAuthenticationProvider('B'));
     $this->assertSame([[LogLevel::WARNING, 'Overriding AuthManager primary authn because testing']], $this->logger->getBuffer());
     $this->logger->clearBuffer();
     // Test with first initializing the configured providers
     $this->initializeManager();
     $this->assertSame($mockA, $this->managerPriv->getAuthenticationProvider('A'));
     $this->assertSame(null, $this->managerPriv->getAuthenticationProvider('B'));
     $this->request->getSession()->setSecret('AuthManager::authnState', 'test');
     $this->request->getSession()->setSecret('AuthManager::accountCreationState', 'test');
     $this->manager->forcePrimaryAuthenticationProviders([$mockB], 'testing');
     $this->assertSame(['B' => $mockB], $this->managerPriv->getPrimaryAuthenticationProviders());
     $this->assertSame(null, $this->managerPriv->getAuthenticationProvider('A'));
     $this->assertSame($mockB, $this->managerPriv->getAuthenticationProvider('B'));
     $this->assertNull($this->request->getSession()->getSecret('AuthManager::authnState'));
     $this->assertNull($this->request->getSession()->getSecret('AuthManager::accountCreationState'));
     $this->assertSame([[LogLevel::WARNING, 'Overriding AuthManager primary authn because testing'], [LogLevel::WARNING, 'PrimaryAuthenticationProviders have already been accessed! I hope nothing breaks.']], $this->logger->getBuffer());
     $this->logger->clearBuffer();
     // Test duplicate IDs
     $this->initializeManager();
     try {
         $this->manager->forcePrimaryAuthenticationProviders([$mockB, $mockB2], 'testing');
         $this->fail('Expected exception not thrown');
     } catch (\RuntimeException $ex) {
         $class1 = get_class($mockB);
         $class2 = get_class($mockB2);
         $this->assertSame("Duplicate specifications for id B (classes {$class2} and {$class1})", $ex->getMessage());
     }
     // Wrong classes
     $mock = $this->getMockForAbstractClass(AuthenticationProvider::class);
     $mock->expects($this->any())->method('getUniqueId')->will($this->returnValue('X'));
     $class = get_class($mock);
     try {
         $this->manager->forcePrimaryAuthenticationProviders([$mock], 'testing');
         $this->fail('Expected exception not thrown');
     } catch (\RuntimeException $ex) {
         $this->assertSame("Expected instance of MediaWiki\\Auth\\PrimaryAuthenticationProvider, got {$class}", $ex->getMessage());
     }
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:53,代码来源:AuthManagerTest.php


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