summaryrefslogtreecommitdiff
path: root/tests/units/Core/Ldap/LdapUserTest.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-05-07 12:59:35 -0400
committerFrederic Guillot <fred@kanboard.net>2016-05-07 12:59:35 -0400
commit300dabe6b4e9e648c1111363fad8154def7cfb5f (patch)
tree1eb9cac2b56401e3c6f0fe8b46233f01909d4885 /tests/units/Core/Ldap/LdapUserTest.php
parent94989663eca0d0dc2e9adb6d3190f0ab3cca9d2a (diff)
Added support for LDAP user photo profile
Diffstat (limited to 'tests/units/Core/Ldap/LdapUserTest.php')
-rw-r--r--tests/units/Core/Ldap/LdapUserTest.php70
1 files changed, 70 insertions, 0 deletions
diff --git a/tests/units/Core/Ldap/LdapUserTest.php b/tests/units/Core/Ldap/LdapUserTest.php
index d861871e..02b9331e 100644
--- a/tests/units/Core/Ldap/LdapUserTest.php
+++ b/tests/units/Core/Ldap/LdapUserTest.php
@@ -52,6 +52,7 @@ class LdapUserTest extends Base
'getAttributeEmail',
'getAttributeName',
'getAttributeGroup',
+ 'getAttributePhoto',
'getGroupUserFilter',
'getGroupAdminDn',
'getGroupManagerDn',
@@ -136,10 +137,79 @@ class LdapUserTest extends Base
$this->assertEquals('My LDAP user', $user->getName());
$this->assertEquals('user1@localhost', $user->getEmail());
$this->assertEquals(Role::APP_USER, $user->getRole());
+ $this->assertSame('', $user->getPhoto());
$this->assertEquals(array(), $user->getExternalGroupIds());
$this->assertEquals(array('is_ldap_user' => 1), $user->getExtraAttributes());
}
+ public function testGetUserWithPhoto()
+ {
+ $entries = new Entries(array(
+ 'count' => 1,
+ 0 => array(
+ 'count' => 2,
+ 'dn' => 'uid=my_ldap_user,ou=People,dc=kanboard,dc=local',
+ 'displayname' => array(
+ 'count' => 1,
+ 0 => 'My LDAP user',
+ ),
+ 'mail' => array(
+ 'count' => 2,
+ 0 => 'user1@localhost',
+ 1 => 'user2@localhost',
+ ),
+ 'samaccountname' => array(
+ 'count' => 1,
+ 0 => 'my_ldap_user',
+ ),
+ 'jpegPhoto' => array(
+ 'count' => 1,
+ 0 => 'my photo',
+ ),
+ 0 => 'displayname',
+ 1 => 'mail',
+ 2 => 'samaccountname',
+ )
+ ));
+
+ $this->client
+ ->expects($this->any())
+ ->method('getConnection')
+ ->will($this->returnValue('my_ldap_resource'));
+
+ $this->query
+ ->expects($this->once())
+ ->method('execute')
+ ->with(
+ $this->equalTo('ou=People,dc=kanboard,dc=local'),
+ $this->equalTo('(uid=my_ldap_user)')
+ );
+
+ $this->query
+ ->expects($this->once())
+ ->method('hasResult')
+ ->will($this->returnValue(true));
+
+ $this->query
+ ->expects($this->once())
+ ->method('getEntries')
+ ->will($this->returnValue($entries));
+
+ $this->user
+ ->expects($this->any())
+ ->method('getAttributePhoto')
+ ->will($this->returnValue('jpegPhoto'));
+
+ $this->user
+ ->expects($this->any())
+ ->method('getBasDn')
+ ->will($this->returnValue('ou=People,dc=kanboard,dc=local'));
+
+ $user = $this->user->find('(uid=my_ldap_user)');
+ $this->assertInstanceOf('Kanboard\User\LdapUserProvider', $user);
+ $this->assertEquals('my photo', $user->getPhoto());
+ }
+
public function testGetUserWithAdminRole()
{
$entries = new Entries(array(