diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-07-02 18:23:47 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-07-02 18:23:47 -0400 |
commit | a8a8bfb0afdd105980181a5fa11701028ff5adfe (patch) | |
tree | b2f7d22a03e660aa76b039703158811c3589fbe3 | |
parent | 43337d58c0be097ca510f2abd1497f13f25bda5b (diff) |
Added more unit tests for LDAP user class
-rw-r--r-- | app/Core/Ldap/User.php | 8 | ||||
-rw-r--r-- | tests/units/Core/Ldap/LdapUserTest.php | 60 |
2 files changed, 64 insertions, 4 deletions
diff --git a/app/Core/Ldap/User.php b/app/Core/Ldap/User.php index 91b48530..4bc1f5f9 100644 --- a/app/Core/Ldap/User.php +++ b/app/Core/Ldap/User.php @@ -116,7 +116,7 @@ class User */ protected function getRole(array $groupIds) { - if ($this->hasGroupsNotConfigured()) { + if (! $this->hasGroupsConfigured()) { return null; } @@ -278,14 +278,14 @@ class User } /** - * Return true if LDAP Group mapping is not configured + * Return true if LDAP Group mapping are configured * * @access public * @return boolean */ - public function hasGroupsNotConfigured() + public function hasGroupsConfigured() { - return !$this->getGroupAdminDn() && !$this->getGroupManagerDn(); + return $this->getGroupAdminDn() || $this->getGroupManagerDn(); } /** diff --git a/tests/units/Core/Ldap/LdapUserTest.php b/tests/units/Core/Ldap/LdapUserTest.php index 505b8a03..143a8c0d 100644 --- a/tests/units/Core/Ldap/LdapUserTest.php +++ b/tests/units/Core/Ldap/LdapUserTest.php @@ -845,4 +845,64 @@ class LdapUserTest extends Base $this->assertTrue($this->user->hasGroupUserFilter()); } + + public function testHasGroupsConfigured() + { + $this->user + ->expects($this->any()) + ->method('getGroupAdminDn') + ->will($this->returnValue('something')); + + $this->user + ->expects($this->any()) + ->method('getGroupManagerDn') + ->will($this->returnValue('something')); + + $this->assertTrue($this->user->hasGroupsConfigured()); + } + + public function testHasGroupAdminDnConfigured() + { + $this->user + ->expects($this->any()) + ->method('getGroupAdminDn') + ->will($this->returnValue('something')); + + $this->user + ->expects($this->any()) + ->method('getGroupManagerDn') + ->will($this->returnValue('')); + + $this->assertTrue($this->user->hasGroupsConfigured()); + } + + public function testHasGroupManagerDnConfigured() + { + $this->user + ->expects($this->any()) + ->method('getGroupAdminDn') + ->will($this->returnValue('')); + + $this->user + ->expects($this->any()) + ->method('getGroupManagerDn') + ->will($this->returnValue('something')); + + $this->assertTrue($this->user->hasGroupsConfigured()); + } + + public function testHasGroupsNotConfigured() + { + $this->user + ->expects($this->any()) + ->method('getGroupAdminDn') + ->will($this->returnValue('')); + + $this->user + ->expects($this->any()) + ->method('getGroupManagerDn') + ->will($this->returnValue('')); + + $this->assertFalse($this->user->hasGroupsConfigured()); + } } |