From 323bdadfae14d0855f0aad8c34a5336b174f648e Mon Sep 17 00:00:00 2001 From: Ujjwal Ojha Date: Thu, 28 Aug 2014 15:36:37 +0545 Subject: [PATCH] Fixed fatal error on missing argument --- src/Factory/Oauth2ClientGrantFactory.php | 3 +- .../Factory/Oauth2ClientGrantFactoryTest.php | 78 +++++++++++++++++++ 2 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 tests/src/Factory/Oauth2ClientGrantFactoryTest.php diff --git a/src/Factory/Oauth2ClientGrantFactory.php b/src/Factory/Oauth2ClientGrantFactory.php index fa36961..f8e0b24 100644 --- a/src/Factory/Oauth2ClientGrantFactory.php +++ b/src/Factory/Oauth2ClientGrantFactory.php @@ -17,7 +17,8 @@ public function createService(ServiceLocatorInterface $grants) $serviceLocator->get('Hrevert\OauthClient\Manager\ProviderManager'), $serviceLocator->get('Hrevert\OauthClient\Manager\UserProviderManager'), $serviceLocator->get('HtLeagueOauthClientModule\Oauth2ClientManager'), - $serviceLocator->get('HtOauth\Server\ClientModule\Options\ModuleOptions') + $serviceLocator->get('HtOauth\Server\ClientModule\Options\ModuleOptions'), + $serviceLocator->get('ht_oauth_client_doctrine_em') ); } } diff --git a/tests/src/Factory/Oauth2ClientGrantFactoryTest.php b/tests/src/Factory/Oauth2ClientGrantFactoryTest.php new file mode 100644 index 0000000..8543c2b --- /dev/null +++ b/tests/src/Factory/Oauth2ClientGrantFactoryTest.php @@ -0,0 +1,78 @@ +getMockBuilder('ZfrOAuth2\Server\Service\TokenService') + ->disableOriginalConstructor() + ->getMock(); + + $refreshTokenService = $this->getMockBuilder('ZfrOAuth2\Server\Service\TokenService') + ->disableOriginalConstructor() + ->getMock(); + + $providerManager = $this->getMock('Hrevert\OauthClient\Manager\ProviderManagerInterface'); + $userProviderManager = $this->getMock('Hrevert\OauthClient\Manager\UserProviderManagerInterface'); + $providerClients = $this->getMock('Zend\ServiceManager\ServiceLocatorInterface'); + + $authorizationServer = $this->getMockBuilder('ZfrOAuth2\Server\AuthorizationServer') + ->disableOriginalConstructor() + ->getMock(); + + $options = $this->getMockBuilder('HtOauth\Server\ClientModule\Options\ModuleOptions') + ->disableOriginalConstructor() + ->getMock(); + + $objectManager = $this->getMock('Doctrine\Common\Persistence\ObjectManager'); + + $serviceLocator = $this->getMock('Zend\ServiceManager\ServiceLocatorInterface'); + + $serviceLocator->expects($this->at(0)) + ->method('get') + ->with('ZfrOAuth2\Server\Service\AccessTokenService') + ->will($this->returnValue($accessTokenService)); + + $serviceLocator->expects($this->at(1)) + ->method('get') + ->with('ZfrOAuth2\Server\Service\RefreshTokenService') + ->will($this->returnValue($refreshTokenService)); + + $serviceLocator->expects($this->at(2)) + ->method('get') + ->with('Hrevert\OauthClient\Manager\ProviderManager') + ->will($this->returnValue($providerManager)); + + $serviceLocator->expects($this->at(3)) + ->method('get') + ->with('Hrevert\OauthClient\Manager\UserProviderManager') + ->will($this->returnValue($userProviderManager)); + + $serviceLocator->expects($this->at(4)) + ->method('get') + ->with('HtLeagueOauthClientModule\Oauth2ClientManager') + ->will($this->returnValue($providerClients)); + + $serviceLocator->expects($this->at(5)) + ->method('get') + ->with('HtOauth\Server\ClientModule\Options\ModuleOptions') + ->will($this->returnValue($options)); + + $serviceLocator->expects($this->at(6)) + ->method('get') + ->with('ht_oauth_client_doctrine_em') + ->will($this->returnValue($objectManager)); + + + $grants = $this->getMock('Zend\ServiceManager\AbstractPluginManager'); + $grants->expects($this->once()) + ->method('getServiceLocator') + ->will($this->returnValue($serviceLocator)); + + $factory = new Oauth2ClientGrantFactory; + $this->assertInstanceOf('HtOauth\Server\ClientModule\Grant\Oauth2Client', $factory->createService($grants)); + } +}