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\DataObject(['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\DataObject([]))); $this->_integrationServiceMock->expects($this->once())->method('update')->with($intUpdateData1); $this->_integrationManager->processIntegrationConfig(['TestIntegration1', 'TestIntegration2']); }
public function testProcessIntegrationConfigCreateNewIntegrations() { $integrations = ['TestIntegration1' => [Integration::EMAIL => '*****@*****.**', Integration::ENDPOINT => 'http://endpoint.com', Integration::IDENTITY_LINK_URL => 'http://www.example.com/identity'], 'TestIntegration2' => [Integration::EMAIL => '*****@*****.**', Integration::ENDPOINT => 'http://endpoint.com', Integration::IDENTITY_LINK_URL => 'http://www.example.com/identity']]; $newResources = ['Magento_Customer::manage', 'Magento_Customer::customer']; $this->_integrationConfigMock->expects($this->once())->method('getIntegrations')->willReturn($newResources); $integrationObject = $this->getMockBuilder('Magento\\Integration\\Model\\Integration')->disableOriginalConstructor()->setMethods([])->getMock(); // Integration1 does not exist, so create it $this->_integrationServiceMock->expects($this->at(0))->method('findByName')->with('TestIntegration1')->will($this->returnValue($integrationObject)); $integrationObject->expects($this->any())->method('getId')->willReturn(false); $this->_integrationServiceMock->expects($this->any())->method('create'); // Integration2 does not exist, so create it $this->_integrationServiceMock->expects($this->at(2))->method('findByName')->with('TestIntegration2')->will($this->returnValue($integrationObject)); $this->_integrationManager->processIntegrationConfig($integrations); }
/** * {@inheritdoc} */ public function processIntegrationConfig(array $integrationNames) { $pluginInfo = $this->pluginList->getNext($this->subjectType, 'processIntegrationConfig'); if (!$pluginInfo) { return parent::processIntegrationConfig($integrationNames); } else { return $this->___callPlugins('processIntegrationConfig', func_get_args(), $pluginInfo); } }
/** * {@inheritdoc} */ public function install(SchemaSetupInterface $setup, ModuleContextInterface $context) { $this->integrationManager->processIntegrationConfig($this->integrationConfig->getIntegrations()); }
/** * {@inheritdoc} */ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { $this->integrationManager->processIntegrationConfig(['Test Integration1']); }