From ddb73063a7889c8dad79dd7148c01c9bc845d9f0 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Mon, 18 Jan 2016 21:20:35 -0500 Subject: Return the highest role for a project when a user is member of multiple groups --- tests/units/Core/Security/AccessMapTest.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests/units/Core') diff --git a/tests/units/Core/Security/AccessMapTest.php b/tests/units/Core/Security/AccessMapTest.php index 61693ce8..ae8044c9 100644 --- a/tests/units/Core/Security/AccessMapTest.php +++ b/tests/units/Core/Security/AccessMapTest.php @@ -17,6 +17,20 @@ class AccessMapTest extends Base $this->assertEquals(array('user', 'admin', 'manager'), $acl->getRoleHierarchy('user')); } + public function testGetHighestRole() + { + $acl = new AccessMap; + $acl->setRoleHierarchy('manager', array('member', 'viewer')); + $acl->setRoleHierarchy('member', array('viewer')); + + $this->assertEquals('manager', $acl->getHighestRole(array('viewer', 'manager', 'member'))); + $this->assertEquals('manager', $acl->getHighestRole(array('viewer', 'manager'))); + $this->assertEquals('manager', $acl->getHighestRole(array('manager', 'member'))); + $this->assertEquals('member', $acl->getHighestRole(array('viewer', 'member'))); + $this->assertEquals('member', $acl->getHighestRole(array('member'))); + $this->assertEquals('viewer', $acl->getHighestRole(array('viewer'))); + } + public function testAddRulesAndGetRoles() { $acl = new AccessMap; -- cgit v1.2.3