/** * Check if access to the specified resources is prohibited to the user. * * @param int $integrationId * @param string[] $resources */ protected function _ensurePermissionsAreNotGranted($integrationId, $resources) { $this->userContextMock->expects($this->any())->method('getUserId')->will($this->returnValue($integrationId)); foreach ($resources as $resource) { $this->assertFalse($this->libAuthorization->isAllowed($resource), "Access to resource '{$resource}' is expected to be prohibited."); } }
/** * {@inheritdoc} */ public function isAllowed($resource, $privilege = null) { $pluginInfo = $this->pluginList->getNext($this->subjectType, 'isAllowed'); if (!$pluginInfo) { return parent::isAllowed($resource, $privilege); } else { return $this->___callPlugins('isAllowed', func_get_args(), $pluginInfo); } }
/** * Check current user permission on resource and privilege * * @param string $resource * @param string $privilege * @return boolean */ public function isAllowed($resource, $privilege = null) { return $resource == 'Magento_Sales::create' ? false : parent::isAllowed($resource, $privilege); }
public function testUpdate() { $arguments = ['cancel_order' => null, 'hold_order' => null, 'unhold_order' => null, 'other' => null]; $this->authorizationMock->expects($this->exactly(3))->method('isAllowed')->willReturnMap([['Magento_Sales::cancel', null, false], ['Magento_Sales::hold', null, false], ['Magento_Sales::unhold', null, false]]); $this->assertEquals(['other' => null], $this->itemUpdater->update($arguments)); }
/** * @param bool $isAllowed * @param bool $expectedResult * @dataProvider isHiddenDataProvider */ public function testIsHidden($isAllowed, $expectedResult) { $this->authorizationMock->expects($this->any())->method('isAllowed')->with('Magento_Sales::transactions_fetch')->willReturn($isAllowed); $this->assertEquals($expectedResult, $this->transactionsTab->isHidden()); }