protected function setUp() { $this->_helper = new Magento_Test_Helper_ObjectManager($this); $this->_objectManager = $this->getMockBuilder('Magento_ObjectManager')->disableOriginalConstructor()->setMethods(array('create'))->getMockForAbstractClass(); $this->_roleResource = $this->getMockBuilder('Mage_Webapi_Model_Resource_Acl_Role')->disableOriginalConstructor()->setMethods(array('getIdFieldName', 'getReadConnection'))->getMock(); $this->_roleResource->expects($this->any())->method('getIdFieldName')->withAnyParameters()->will($this->returnValue('id')); $this->_roleResource->expects($this->any())->method('getReadConnection')->withAnyParameters()->will($this->returnValue($this->getMock('Varien_Db_Adapter_Pdo_Mysql', array(), array(), '', false))); }
/** * Test for Mage_Webapi_Model_Authorization_Loader_Role::populateAcl * * Test with No existing role Ids */ public function testPopulateAclWithNoRoles() { $this->_resourceModelMock->expects($this->once())->method('getRolesIds')->will($this->returnValue(array())); $this->_roleFactory->expects($this->never())->method('createRole'); $this->_acl->expects($this->never())->method('addRole'); $this->_acl->expects($this->never())->method('deny'); $this->_model->populateAcl($this->_acl); }
/** * Populate ACL with roles from external storage. * * @param Magento_Acl $acl */ public function populateAcl(Magento_Acl $acl) { $roleList = $this->_roleResource->getRolesIds(); foreach ($roleList as $roleId) { /** @var $aclRole Mage_Webapi_Model_Authorization_Role */ $aclRole = $this->_roleFactory->createRole(array($roleId)); $acl->addRole($aclRole); //Deny all privileges to Role. Some of them could be allowed later by whitelist $acl->deny($aclRole); } }