diff --git a/CHANGELOG.md b/CHANGELOG.md index e0cb9b2b..248250cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,7 +59,9 @@ - Enh #252: Return `$this` instead of throwing "already assigned" exception in `Manager::assign()` (@arogachev) - Enh #248: Add `SimpleRuleFactory` (@arogachev) - Enh #251: Allow checking for user's roles in `ManagerInterface::userHasPermission()` (@arogachev) -- Chg #259: Rename `$ruleContext` argument to `$context` in `RuleInterface::execute()` (@arogachev) +- Chg #259: Rename `$ruleContext` argument to `$context` in `RuleInterface::execute()` (@arogachev) +- Bug #260: Fix `Manager::userHasPermission()` to return `true` for the case when a user have access via at least one + hierarchy branch (@arogachev) ## 1.0.2 April 20, 2023 diff --git a/src/Manager.php b/src/Manager.php index 4a950add..ea76b2ee 100644 --- a/src/Manager.php +++ b/src/Manager.php @@ -70,10 +70,6 @@ public function userHasPermission( } $hierarchy = $this->itemsStorage->getHierarchy($item->getName()); - if ($guestRole !== null && !array_key_exists($guestRole->getName(), $hierarchy)) { - $hierarchy[$guestRole->getName()] = ['item' => $guestRole, 'children' => []]; - } - $itemNames = array_map(static fn (array $treeItem): string => $treeItem['item']->getName(), $hierarchy); $userItemNames = $guestRole !== null ? [$guestRole->getName()] diff --git a/tests/Common/ManagerLogicTestTrait.php b/tests/Common/ManagerLogicTestTrait.php index a14cfdb1..9c2a95e3 100644 --- a/tests/Common/ManagerLogicTestTrait.php +++ b/tests/Common/ManagerLogicTestTrait.php @@ -298,7 +298,7 @@ public function testUserHasPermissionWithRolesAllowed( ); } - public function testUserHasPermissionTemp(): void + public function testUserHasPermissionWithOneHierarchyBranch(): void { $manager = $this ->createFilledManager()