Ejemplo n.º 1
0
 /**
  * Add list of nodes and their children to acl
  *
  * @param Acl $acl
  * @param array $resources
  * @param AclResource $parent
  * @return void
  * @throws \InvalidArgumentException
  */
 protected function _addResourceTree(Acl $acl, array $resources, AclResource $parent = null)
 {
     foreach ($resources as $resourceConfig) {
         if (!isset($resourceConfig['id'])) {
             throw new \InvalidArgumentException('Missing ACL resource identifier');
         }
         /** @var $resource AclResource */
         $resource = $this->_resourceFactory->createResource(['resourceId' => $resourceConfig['id']]);
         $acl->addResource($resource, $parent);
         if (isset($resourceConfig['children'])) {
             $this->_addResourceTree($acl, $resourceConfig['children'], $resource);
         }
     }
 }
 public function testCreateResource()
 {
     $arguments = ['5', '6'];
     $this->_objectManager->expects($this->once())->method('create')->with('Magento\\Framework\\Acl\\AclResource', $arguments)->will($this->returnValue($this->_expectedObject));
     $this->assertEquals($this->_expectedObject, $this->_model->createResource($arguments));
 }