public function testProcessConfigBasedIntegrationsRecreateUpdatedConfigAfterResourceChange() { $originalData = [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]; $integrations = ['TestIntegration1' => [Integration::EMAIL => '*****@*****.**', Integration::ENDPOINT => 'http://endpoint.com', Integration::IDENTITY_LINK_URL => 'http://www.example.com/identity', 'resources' => ['Magento_Customer::manage', 'Magento_Customer::customer']]]; $originalResources = ['Magento_Customer::manage']; $newResources = ['Magento_Customer::manage', 'Magento_Customer::customer']; $integrationObject = $this->getMockBuilder('Magento\\Integration\\Model\\Integration')->disableOriginalConstructor()->setMethods([])->getMock(); // Integration already exists, so update with new data and recreate $this->integrationServiceMock->expects($this->at(0))->method('findByName')->with('TestIntegration1')->will($this->returnValue($integrationObject)); $this->aclRetriever->expects($this->once())->method('getAllowedResourcesByUser')->willReturn($originalResources); $integrationObject->expects($this->any())->method('getId')->willReturn($originalData[Integration::ID]); $this->integrationServiceMock->expects($this->once())->method('update')->willReturn($integrationObject); $integrationObject->expects($this->once())->method('getOrigData')->willReturn($originalData); $integrationObject->expects($this->once())->method('getData')->willReturn($newResources); $this->integrationServiceMock->expects($this->once())->method('create'); $this->integrationManager->processConfigBasedIntegrations($integrations); }
public function testAfterGet() { $integrationId = 1; $integrationModelMock = $this->getMockBuilder('Magento\\Integration\\Model\\Integration')->disableOriginalConstructor()->getMock(); $integrationModelMock->expects($this->exactly(2))->method('getId')->will($this->returnValue($integrationId)); $integrationModelMock->expects($this->once())->method('setData')->with('resource', ['testResource']); $this->aclRetrieverMock->expects($this->once())->method('getAllowedResourcesByUser')->with(\Magento\Authorization\Model\UserContextInterface::USER_TYPE_INTEGRATION, $integrationId)->will($this->returnValue(['testResource'])); $this->integrationPlugin->afterGet($this->subjectMock, $integrationModelMock); }
public function testAfterGet() { $integrationId = 1; $integrationModelMock = $this->getMockBuilder('Magento\\Integration\\Model\\Integration')->disableOriginalConstructor()->getMock(); $integrationModelMock->expects($this->exactly(2))->method('getId')->will($this->returnValue($integrationId)); $integrationModelMock->expects($this->once())->method('setData')->with('resource', ['testResource']); $deprecatedIntegrationsData = [Integration::ID => $integrationId, Integration::NAME => 'TestIntegration1', Integration::EMAIL => '*****@*****.**', Integration::ENDPOINT => 'http://endpoint.com', Integration::SETUP_TYPE => 1, 'resource' => ['testResource']]; $consolidatedIntegrationsData = [Integration::ID => 2, Integration::NAME => 'TestIntegration2', Integration::EMAIL => '*****@*****.**', Integration::ENDPOINT => 'http://endpoint2.com', Integration::SETUP_TYPE => 1, 'resource' => ['testResource']]; $this->integrationConfigMock->method('getIntegrations')->willReturn($deprecatedIntegrationsData); $this->consolidatedConfigMock->method('getIntegrations')->willReturn($consolidatedIntegrationsData); $this->aclRetrieverMock->expects($this->once())->method('getAllowedResourcesByUser')->with(\Magento\Authorization\Model\UserContextInterface::USER_TYPE_INTEGRATION, $integrationId)->will($this->returnValue(['testResource'])); $this->integrationPlugin->afterGet($this->subjectMock, $integrationModelMock); }