/**
  * {@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);
     }
 }
Example #2
0
 /**
  * @dataProvider isAllowedDataProvider
  * @param bool $isUserDefined
  * @param bool $isAclDefined
  * @param bool $isAllowed
  * @param true $expectedResult
  */
 public function testIsAllowed($isUserDefined, $isAclDefined, $isAllowed, $expectedResult)
 {
     $userAclRole = 'userAclRole';
     if ($isAclDefined) {
         $aclMock = $this->getMockBuilder('Magento\\Framework\\Acl')->disableOriginalConstructor()->getMock();
         $this->storage->expects($this->any())->method('getAcl')->willReturn($aclMock);
     }
     if ($isUserDefined) {
         $userMock = $this->getMockBuilder('Magento\\User\\Model\\User')->disableOriginalConstructor()->getMock();
         $this->storage->expects($this->once())->method('getUser')->willReturn($userMock);
     }
     if ($isAclDefined && $isUserDefined) {
         $userMock->expects($this->any())->method('getAclRole')->willReturn($userAclRole);
         $aclMock->expects($this->once())->method('isAllowed')->with($userAclRole)->willReturn($isAllowed);
     }
     $this->assertEquals($expectedResult, $this->session->isAllowed('resource'));
 }
Example #3
0
 /**
  * 'true' - if admin user has right to use 'Login As' feature.
  * @return bool
  */
 public static function canAccessLoginAs()
 {
     return filter_var($this->_modelAuthSession->isAllowed('customer/prxgt_lgas_access'), FILTER_VALIDATE_BOOLEAN);
 }