Skip to content

Commit

Permalink
Merge branch 'hotfix/3513'
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Jan 22, 2013
2 parents a219656 + 05f1488 commit 960e722
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
6 changes: 4 additions & 2 deletions library/Zend/Permissions/Acl/Acl.php
Expand Up @@ -572,9 +572,11 @@ public function setRule($operation, $type, $roles = null, $resources = null,
$resources = array();
foreach ($resourcesTemp as $resource) {
if (null !== $resource) {
$children = $this->getChildResources($this->getResource($resource));
$resourceObj = $this->getResource($resource);
$resourceId = $resourceObj->getResourceId();
$children = $this->getChildResources($resourceObj);
$resources = array_merge($resources, $children);
$resources[$resource] = $this->getResource($resource);
$resources[$resourceId] = $resourceObj;
} else {
$resources[] = null;
}
Expand Down
11 changes: 11 additions & 0 deletions tests/ZendTest/Permissions/Acl/AclTest.php
Expand Up @@ -1328,4 +1328,15 @@ public function testAclResourcePermissionsAreInheritedWithMultilevelResourcesAnd
$this->assertFalse($this->_acl->isAllowed('guest', 'post_1', 'comment'));
$this->assertFalse($this->_acl->isAllowed('guest', 'post_2', 'comment'));
}

public function testSetRuleWorksWithResourceInterface()
{
$roleGuest = new Role\GenericRole('guest');
$this->_acl->addRole($roleGuest);

$resourceFoo = new Resource\GenericResource('foo');
$this->_acl->addResource($resourceFoo);

$this->_acl->setRule(Acl\Acl::OP_ADD, Acl\Acl::TYPE_ALLOW, $roleGuest, $resourceFoo);
}
}

0 comments on commit 960e722

Please sign in to comment.