/** * @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); }
/** * @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()); }
/** * @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()); }
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()); }