public function testAfterUpdateAllResources() { $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('getData')->with('all_resources')->will($this->returnValue(1)); $this->integrationAuthServiceMock->expects($this->once())->method('grantAllPermissions')->with($integrationId); $this->integrationPlugin->afterUpdate($this->subjectMock, $integrationModelMock); }
/** * Process integration resource permissions after the integration is created * * @param IntegrationServiceInterface $subject * @param array $integrationData Data of integration deleted * * @return array $integrationData * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function afterDelete(IntegrationServiceInterface $subject, array $integrationData) { //No check needed for integration data since it cannot be empty in the parent invocation - delete $integrationId = (int) $integrationData[IntegrationModel::ID]; $this->integrationAuthorizationService->removePermissions($integrationId); return $integrationData; }
/** * Process integration resource permissions after the integration is created * * @param ConfigBasedIntegrationManager $subject * @param array $integrations integrations passed as array from the invocation chain * * @return array * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function afterProcessIntegrationConfig(ConfigBasedIntegrationManager $subject, $integrations) { if (empty($integrations)) { return []; } /** @var array $integrationsResource */ $integrationsResource = $this->_integrationConfig->getIntegrations(); foreach (array_keys($integrations) as $name) { if (isset($integrationsResource[$name])) { $integration = $this->_integrationService->findByName($name); if ($integration->getId()) { $this->integrationAuthorizationService->grantPermissions($integration->getId(), $integrationsResource[$name]['resource']); } } } return $integrations; }