15 public function testPopulateAclOnValidObjects()
18 $aclResource = $this->createMock(\
Magento\Framework\
Acl\AclResource::class);
21 $acl = $this->createPartialMock(\
Magento\Framework\Acl::class, [
'addResource']);
22 $acl->expects($this->exactly(2))->method(
'addResource');
23 $acl->expects($this->at(0))->method(
'addResource')->with($aclResource,
null)->will($this->returnSelf());
24 $acl->expects($this->at(1))->method(
'addResource')->with($aclResource, $aclResource)->will($this->returnSelf());
26 $factoryObject = $this->createPartialMock(\
Magento\Framework\
Acl\AclResourceFactory::class, [
'createResource']);
27 $factoryObject->expects($this->any())->method(
'createResource')->will($this->returnValue($aclResource));
31 $resourceProvider->expects($this->once())
32 ->method(
'getAclResources')
37 'id' =>
'parent_resource::id',
38 'title' =>
'Parent Resource Title',
42 'id' =>
'child_resource::id',
43 'title' =>
'Child Resource Title',
54 $loaderResource = new \Magento\Framework\Acl\Loader\ResourceLoader($resourceProvider, $factoryObject);
56 $loaderResource->populateAcl($acl);
65 public function testPopulateAclWithException()
68 $aclResource = $this->createMock(\
Magento\Framework\
Acl\AclResource::class);
70 $factoryObject = $this->getMockBuilder(\
Magento\Framework\
Acl\AclResourceFactory::class)
71 ->setMethods([
'createResource'])
72 ->disableOriginalConstructor()
75 $factoryObject->expects($this->any())->method(
'createResource')->will($this->returnValue($aclResource));
79 $resourceProvider->expects($this->once())
80 ->method(
'getAclResources')
85 'title' =>
'Parent Resource Title',
89 'id' =>
'child_resource::id',
90 'title' =>
'Child Resource Title',
101 $acl = $this->createPartialMock(\
Magento\Framework\Acl::class, [
'addResource']);
104 $loaderResource = new \Magento\Framework\Acl\Loader\ResourceLoader($resourceProvider, $factoryObject);
106 $loaderResource->populateAcl($acl);