Added more unit tests for LDAP user class
This commit is contained in:
@@ -116,7 +116,7 @@ class User
|
|||||||
*/
|
*/
|
||||||
protected function getRole(array $groupIds)
|
protected function getRole(array $groupIds)
|
||||||
{
|
{
|
||||||
if ($this->hasGroupsNotConfigured()) {
|
if (! $this->hasGroupsConfigured()) {
|
||||||
return null;
|
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
|
* @access public
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function hasGroupsNotConfigured()
|
public function hasGroupsConfigured()
|
||||||
{
|
{
|
||||||
return !$this->getGroupAdminDn() && !$this->getGroupManagerDn();
|
return $this->getGroupAdminDn() || $this->getGroupManagerDn();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -845,4 +845,64 @@ class LdapUserTest extends Base
|
|||||||
|
|
||||||
$this->assertTrue($this->user->hasGroupUserFilter());
|
$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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user