*/ class AuthenticationIdentityProviderServiceFactoryTest extends PHPUnit_Framework_TestCase { /** * @covers BjyAuthorize\Service\AuthenticationIdentityProviderServiceFactory::createService * @covers BjyAuthorize\Provider\Identity\AuthenticationIdentityProvider::getDefaultRole * @covers BjyAuthorize\Provider\Identity\AuthenticationIdentityProvider::getAuthenticatedRole */ public function testCreateService() { $config = array( 'default_role' => 'test-guest', 'authenticated_role' => 'test-user', ); $user = $this->getMock('ZfcUser\\Service\\User', array('getAuthService')); $auth = $this->getMock('Zend\\Authentication\\AuthenticationService'); $serviceLocator = $this->getMock('Zend\\ServiceManager\\ServiceLocatorInterface'); $user->expects($this->once())->method('getAuthService')->will($this->returnValue($auth)); $serviceLocator ->expects($this->any()) ->method('get') ->will($this->returnCallback(function ($service) use ($user, $config) { if ('zfcuser_user_service' === $service) { return $user; } if ('BjyAuthorize\Config' === $service) { return $config; } throw new \InvalidArgumentException(); })); $authenticationFactory = new AuthenticationIdentityProviderServiceFactory(); $authentication = $authenticationFactory->createService($serviceLocator); $this->assertEquals($authentication->getDefaultRole(), 'test-guest'); $this->assertEquals($authentication->getAuthenticatedRole(), 'test-user'); } }