public function save() { $postValues = $this->getValues(); $providerId = $postValues['id']; $flag = 'save'; $provider = null; if (isset($providerId) & $providerId != '') { $provider = $this->getOpenIdProviderService()->getOpenIdProvider($providerId); $flag = 'update'; } else { $provider = new OpenidProvider(); $provider->setStatus(1); $flag = 'save'; } $provider->setProviderName($postValues['name']); $provider->setProviderUrl($postValues['url']); $savedProvider = $this->getOpenIdProviderService()->saveOpenIdProvider($provider); if ($savedProvider instanceof OpenidProvider) { $authProviderExtraDetails = $this->getAuthProviderExtraDetailsService()->getAuthProviderDetailsByProviderId($savedProvider->getProviderId()); if (!$authProviderExtraDetails instanceof AuthProviderExtraDetails) { $authProviderExtraDetails = new AuthProviderExtraDetails(); } $authProviderExtraDetails->setProviderId($savedProvider->getProviderId()); $authProviderExtraDetails->setProviderType($postValues['type']); $authProviderExtraDetails->setClientId($postValues['clientId']); $authProviderExtraDetails->setClientSecret($postValues['clientSecret']); $authProviderExtraDetails->setDeveloperKey($postValues['developerKey']); $this->getAuthProviderExtraDetailsService()->saveAuthProviderExtraDetails($authProviderExtraDetails); } return $flag; }
/** * * @param OpenidProvider $openIdProvider * @return OpenidProvider */ public function saveOpenIdProvider(OpenidProvider $openIdProvider) { try { $openIdProvider->save(); $openIdProvider->refresh(); return $openIdProvider; } catch (Exception $e) { throw new DaoException($e->getMessage(), $e->getCode(), $e); } }
/** * * @param OpenidProvider $openIdProvider * @return OpenidProvider */ public function testSaveOpenIdProvider() { $openIdProvider = new OpenidProvider(); $openIdProvider->setProviderName('New Open ID Provider'); $openIdProvider->setProviderUrl('http://new.com/id'); $openIdProvider->setStatus(1); $result = $this->dao->saveOpenIdProvider($openIdProvider); $this->assertTrue($result instanceof OpenidProvider); $this->assertEquals($result->getStatus(), 1); $this->assertEquals($result->getProviderName(), 'New Open ID Provider'); $this->assertEquals($result->getProviderUrl(), 'http://new.com/id'); }
public function save() { $posts = $this->getValues(); $providerId = $posts['id']; $flag = 'save'; $provider = null; if (isset($providerId) & $providerId != '') { $provider = $this->getOpenIdProviderService()->getOpenIdProvider($providerId); $flag = 'update'; } else { $provider = new OpenidProvider(); $provider->setStatus(1); $flag = 'save'; } $provider->setProviderName($posts['name']); $provider->setProviderUrl($posts['url']); $this->getOpenIdProviderService()->saveOpenIdProvider($provider); return $flag; }
/** * Get Open Id Provider by ID * @return OpenidProvider */ public function testGetOpenIdProvider() { $openIdProvider = new OpenidProvider(); $openIdProvider->setId(1); $openIdProvider->setProviderName('Google'); $openIdProvider->setProviderUrl('https://google.com/o/8/'); $openIdProvider->setStatus(1); $openIdProviderDaoMock = $this->getMock('OpenIdProviderDao', array('getOpenIdProvider')); $openIdProviderDaoMock->expects($this->once())->method('getOpenIdProvider')->will($this->returnValue($openIdProvider)); $this->openIdProviderService->setOpenIdProviderDao($openIdProviderDaoMock); $result = $this->openIdProviderService->getOpenIdProvider(1); $this->assertTrue($result instanceof OpenidProvider); $this->assertEquals($result->getId(), 1); $this->assertEquals($result->getStatus(), 1); $this->assertEquals($result->getProviderName(), 'Google'); $this->assertEquals($result->getProviderUrl(), 'https://google.com/o/8/'); }