/**
  * @param bool $isAllowed
  * @dataProvider dataProviderBoolValues
  */
 public function testIsEverythingAllowed($isAllowed)
 {
     $id = 10;
     $this->coreRegistryMock->expects($this->once())->method('registry')->with(\Magento\User\Controller\Adminhtml\User\Role\SaveRole::RESOURCE_ALL_FORM_DATA_SESSION_KEY)->willReturn(true);
     if ($isAllowed) {
         $this->rootResourceMock->expects($this->exactly(2))->method('getId')->willReturnOnConsecutiveCalls($id, $id);
     } else {
         $this->rootResourceMock->expects($this->exactly(2))->method('getId')->willReturnOnConsecutiveCalls(11, $id);
     }
     $this->assertEquals($isAllowed, $this->model->isEverythingAllowed());
 }
Example #2
0
 /**
  * @param string $rootResourceId
  * @param array $savedData
  * @param bool $expectedValue
  * @dataProvider isEverythingAllowedWithSavedFromDataProvider
  */
 public function testIsEverythingAllowedWithSavedFromData($rootResourceId, $savedData, $expectedValue)
 {
     $this->registry->expects($this->once())->method('registry')->with(IntegrationController::REGISTRY_KEY_CURRENT_RESOURCE)->willReturn($savedData);
     $this->rootResource->expects($this->any())->method('getId')->will($this->returnValue($rootResourceId));
     $this->webapiBlock = $this->getWebapiBlock();
     $this->assertEquals($expectedValue, $this->webapiBlock->isEverythingAllowed());
 }
 public function testGrantAllPermissions()
 {
     $rootResource = 'Magento_All:all';
     $this->rootAclResourceMock->expects($this->any())->method('getId')->will($this->returnValue($rootResource));
     $this->roleMock->expects($this->any())->method('getId')->will($this->returnValue(self::ROLE_ID));
     $this->rulesMock->expects($this->any())->method('setRoleId')->with(self::ROLE_ID)->will($this->returnSelf());
     $this->rulesMock->expects($this->any())->method('setResources')->with([$rootResource])->will($this->returnSelf());
     $this->rulesMock->expects($this->any())->method('saveRel')->will($this->returnSelf());
     $this->integrationAuthorizationService->grantAllPermissions(self::INTEGRATION_ID);
 }
 /**
  * @param string $rootResourceId
  * @param array $integrationData
  * @param array $selectedResources
  * @param bool $expectedValue
  * @dataProvider isEverythingAllowedProvider
  */
 public function testIsEverythingAllowed($rootResourceId, $integrationData, $selectedResources, $expectedValue)
 {
     $this->webapiBlock = $this->getWebapiBlock($integrationData, $selectedResources);
     $this->rootResource->expects($this->once())->method('getId')->will($this->returnValue($rootResourceId));
     $this->assertEquals($expectedValue, $this->webapiBlock->isEverythingAllowed());
 }