/** * Process integrations from config files for the given array of integration names * * @param array $integrationNames * @return array * @deprecated */ public function processIntegrationConfig(array $integrationNames) { if (empty($integrationNames)) { return []; } /** @var array $integrations */ $integrations = $this->integrationConfig->getIntegrations(); foreach ($integrationNames as $name) { $integrationDetails = $integrations[$name]; $integrationData = [Integration::NAME => $name]; if (isset($integrationDetails[Converter::KEY_EMAIL])) { $integrationData[Integration::EMAIL] = $integrationDetails[Converter::KEY_EMAIL]; } if (isset($integrationDetails[Converter::KEY_AUTHENTICATION_ENDPOINT_URL])) { $integrationData[Integration::ENDPOINT] = $integrationDetails[Converter::KEY_AUTHENTICATION_ENDPOINT_URL]; } if (isset($integrationDetails[Converter::KEY_IDENTITY_LINKING_URL])) { $integrationData[Integration::IDENTITY_LINK_URL] = $integrationDetails[Converter::KEY_IDENTITY_LINKING_URL]; } $integrationData[Integration::SETUP_TYPE] = Integration::TYPE_CONFIG; // If it already exists, update it $integration = $this->integrationService->findByName($name); if ($integration->getId()) { //If Integration already exists, update it. //For now we will just overwrite the integration with same name but we will need a long term solution $integrationData[Integration::ID] = $integration->getId(); $this->integrationService->update($integrationData); } else { $this->integrationService->create($integrationData); } } return $integrationNames; }
public function testGetIntegrationsFromConfigReader() { $integrations = ['foo', 'bar', 'baz']; $this->configCacheTypeMock->expects($this->once())->method('load')->with(Config::CACHE_ID)->will($this->returnValue(null)); $this->configCacheTypeMock->expects($this->once())->method('save')->with(serialize($integrations), Config::CACHE_ID, [Type::CACHE_TAG])->will($this->returnValue(null)); $this->configReaderMock->expects($this->once())->method('read')->will($this->returnValue($integrations)); $this->assertEquals($integrations, $this->configModel->getIntegrations()); }
/** * Check whether all indices are valid or not * * @return bool */ public function isDisplayed() { foreach (array_keys($this->integrationConfig->getIntegrations()) as $name) { $integration = $this->integrationService->findByName($name); if ($integration->getStatus() == Integration::STATUS_RECREATED) { return true; } } return false; }
public function testProcessIntegrationConfigSuccess() { $this->_integrationConfigMock->expects($this->once())->method('getIntegrations')->will($this->returnValue(['TestIntegration1' => ['email' => '*****@*****.**', 'endpoint_url' => 'http://endpoint.com', 'identity_link_url' => 'http://www.example.com/identity'], 'TestIntegration2' => ['email' => '*****@*****.**']])); $intLookupData1 = new \Magento\Framework\Object(['id' => 1, Integration::NAME => 'TestIntegration1', Integration::SETUP_TYPE => 1]); $intUpdateData1 = [Integration::ID => 1, Integration::NAME => 'TestIntegration1', Integration::EMAIL => '*****@*****.**', Integration::ENDPOINT => 'http://endpoint.com', Integration::IDENTITY_LINK_URL => 'http://www.example.com/identity', Integration::SETUP_TYPE => 1]; $integrationsData2 = [Integration::NAME => 'TestIntegration2', Integration::EMAIL => '*****@*****.**', Integration::SETUP_TYPE => 1]; $this->_integrationServiceMock->expects($this->at(0))->method('findByName')->with('TestIntegration1')->will($this->returnValue($intLookupData1)); $this->_integrationServiceMock->expects($this->once())->method('create')->with($integrationsData2); $this->_integrationServiceMock->expects($this->at(2))->method('findByName')->with('TestIntegration2')->will($this->returnValue(new \Magento\Framework\Object([]))); $this->_integrationServiceMock->expects($this->once())->method('update')->with($intUpdateData1); $this->_integrationManager->processIntegrationConfig(['TestIntegration1', 'TestIntegration2']); }
public function testProcessIntegrationConfigSuccess() { $this->configMock->expects($this->once())->method('getIntegrations')->will($this->returnValue(['TestIntegration1' => ['email' => '*****@*****.**', 'endpoint_url' => 'http://endpoint.com', 'identity_link_url' => 'http://www.example.com/identity'], 'TestIntegration2' => ['email' => '*****@*****.**']])); $intLookupData1 = $this->getMockBuilder('Magento\\Integration\\Model\\Integration')->disableOriginalConstructor()->setMethods([])->getMock(); $intLookupData1->expects($this->any())->method('getId')->willReturn(1); $intLookupData2 = $this->getMockBuilder('Magento\\Integration\\Model\\Integration')->disableOriginalConstructor()->setMethods([])->getMock(); $intLookupData1->expects($this->any())->method('getId')->willReturn(false); $intUpdateData1 = [Integration::ID => 1, Integration::NAME => 'TestIntegration1', Integration::EMAIL => '*****@*****.**', Integration::ENDPOINT => 'http://endpoint.com', Integration::IDENTITY_LINK_URL => 'http://www.example.com/identity', Integration::SETUP_TYPE => 1]; $integrationsData2 = [Integration::NAME => 'TestIntegration2', Integration::EMAIL => '*****@*****.**', Integration::SETUP_TYPE => 1]; $this->integrationServiceMock->expects($this->at(0))->method('findByName')->with('TestIntegration1')->will($this->returnValue($intLookupData1)); $this->integrationServiceMock->expects($this->once())->method('create')->with($integrationsData2); $this->integrationServiceMock->expects($this->at(2))->method('findByName')->with('TestIntegration2')->will($this->returnValue($intLookupData2)); $this->integrationServiceMock->expects($this->at(1))->method('update')->with($intUpdateData1); $this->integrationManager->processIntegrationConfig(['TestIntegration1', 'TestIntegration2']); }
/** * {@inheritdoc} */ public function install(SchemaSetupInterface $setup, ModuleContextInterface $context) { $this->integrationManager->processIntegrationConfig($this->integrationConfig->getIntegrations()); }