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->consolidatedConfig->getIntegrations()) as $name) { $integration = $this->integrationService->findByName($name); if ($integration->getStatus() == Integration::STATUS_RECREATED) { return true; } } return false; }
/** * Add the list of allowed resources to the integration object data by 'resource' key. * * @param IntegrationModel $integration * @return void */ protected function _addAllowedResources(IntegrationModel $integration) { $integrations = array_merge($this->integrationConfig->getIntegrations(), $this->consolidatedConfig->getIntegrations()); if ($integration->getId()) { if ($integration->getSetupType() == IntegrationModel::TYPE_CONFIG) { $integration->setData('resource', $integrations[$integration->getData('name')]['resource']); } else { $integration->setData('resource', $this->aclRetriever->getAllowedResourcesByUser(UserContextInterface::USER_TYPE_INTEGRATION, (int) $integration->getId())); } } }
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); }
/** * {@inheritdoc} */ public function install(SchemaSetupInterface $setup, ModuleContextInterface $context) { $this->integrationManager->processConfigBasedIntegrations($this->integrationConfig->getIntegrations()); }