/** * @return void * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function testAfterProcessIntegrationConfigSuccess() { $testIntegration1Resource = ['Magento_Customer::manage', 'Magento_Customer::online', 'Magento_Sales::create', 'Magento_SalesRule::quote']; $testIntegration2Resource = ['Magento_Catalog::product_read']; $this->integrationConfigMock->expects($this->once())->method('getIntegrations')->will($this->returnValue(['TestIntegration1' => ['resources' => $testIntegration1Resource], 'TestIntegration2' => ['resources' => $testIntegration2Resource]])); $firstInegrationId = 1; $integrationsData1 = new \Magento\Framework\Object(['id' => $firstInegrationId, Integration::NAME => 'TestIntegration1', Integration::EMAIL => '*****@*****.**', Integration::ENDPOINT => 'http://endpoint.com', Integration::SETUP_TYPE => 1]); $secondIntegrationId = 2; $integrationsData2 = new \Magento\Framework\Object(['id' => $secondIntegrationId, Integration::NAME => 'TestIntegration2', Integration::EMAIL => '*****@*****.**', Integration::SETUP_TYPE => 1]); $this->integrationServiceMock->expects($this->at(0))->method('findByName')->with('TestIntegration1')->will($this->returnValue($integrationsData1)); $this->integrationServiceMock->expects($this->at(1))->method('findByName')->with('TestIntegration2')->will($this->returnValue($integrationsData2)); $this->apiSetupPlugin->afterProcessIntegrationConfig($this->subjectMock, ['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); }