*/ class ZfcUserZendDbIdentityProviderServiceFactoryTest extends PHPUnit_Framework_TestCase { /** * @covers \BjyAuthorize\Service\ZfcUserZendDbIdentityProviderServiceFactory::createService */ public function testCreateService() { $factory = new ZfcUserZendDbIdentityProviderServiceFactory(); $serviceLocator = $this->getMock('Zend\\ServiceManager\\ServiceLocatorInterface'); $adapter = $this->getMock('Zend\\Db\\Adapter\\Adapter', array(), array(), '', false); $userService = $this->getMock('ZfcUser\\Service\\User'); $serviceLocator ->expects($this->any()) ->method('get') ->will($this->returnCallback(function ($serviceName) use ($adapter, $userService) { if ('zfcuser_zend_db_adapter' === $serviceName) { return $adapter; } if ('zfcuser_user_service' === $serviceName) { return $userService; } if ('BjyAuthorize\Config' === $serviceName) { return array('default_role' => 'test_role'); } throw new \InvalidArgumentException(); })); $provider = $factory->createService($serviceLocator); $this->assertInstanceOf('BjyAuthorize\\Provider\\Identity\\ZfcUserZendDb', $provider); $this->assertSame('test_role', $provider->getDefaultRole()); } }