本文整理汇总了PHP中Zend\Authentication\AuthenticationService::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP AuthenticationService::expects方法的具体用法?PHP AuthenticationService::expects怎么用?PHP AuthenticationService::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Authentication\AuthenticationService
的用法示例。
在下文中一共展示了AuthenticationService::expects方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetUserSetting
/**
* @dataProvider provideUserInstance
*/
public function testGetUserSetting($instance)
{
if (!$instance) {
$mockUser = $this->getMock('ZfcUser\\Entity\\UserInterface');
$this->authenticationService->expects($this->once())->method('getIdentity')->will($this->returnValue($mockUser));
}
$this->plugin->getUserSetting('allow_email', $instance);
}
示例2: testGetAndHasIdentity
/**
* @covers ZfcUser\Controller\Plugin\ZfcUserAuthentication::hasIdentity
* @covers ZfcUser\Controller\Plugin\ZfcUserAuthentication::getIdentity
*/
public function testGetAndHasIdentity()
{
$this->SUT->setAuthService($this->mockedAuthenticationService);
$callbackIndex = 0;
$callback = function () use(&$callbackIndex) {
$callbackIndex++;
return (bool) ($callbackIndex % 2);
};
$this->mockedAuthenticationService->expects($this->any())->method('hasIdentity')->will($this->returnCallback($callback));
$this->mockedAuthenticationService->expects($this->any())->method('getIdentity')->will($this->returnCallback($callback));
$this->assertTrue($this->SUT->hasIdentity());
$this->assertFalse($this->SUT->hasIdentity());
$this->assertTrue($this->SUT->hasIdentity());
$callbackIndex = 0;
$this->assertTrue($this->SUT->getIdentity());
$this->assertFalse($this->SUT->getIdentity());
$this->assertTrue($this->SUT->getIdentity());
}
示例3: testGetIdentityRolesRetrievesIdentityThatIsARole
/**
* @covers \BjyAuthorize\Provider\Identity\AuthenticationIdentityProvider::getIdentityRoles
*/
public function testGetIdentityRolesRetrievesIdentityThatIsARole()
{
$user = $this->getMock('Zend\\Permissions\\Acl\\Role\\RoleInterface');
$this->authService->expects($this->any())->method('getIdentity')->will($this->returnValue($user));
$this->assertSame(array($user), $this->provider->getIdentityRoles());
}
示例4: testCanReturnIdentity
public function testCanReturnIdentity()
{
$identity = $this->getMock('ZfjRbac\\Identity\\IdentityInterface');
$this->authenticationService->expects($this->once())->method('getIdentity')->will($this->returnValue($identity));
$this->assertSame($identity, $this->identityProvider->getIdentity());
}