public function testExecuteQuerySuccessfully() { $entries = array('count' => 1, 0 => array('count' => 2, 'dn' => 'uid=my_user,ou=People,dc=kanboard,dc=local', 'displayname' => array('count' => 1, 0 => 'My user'), 'mail' => array('count' => 2, 0 => 'user1@localhost', 1 => 'user2@localhost'), 0 => 'displayname', 1 => 'mail')); self::$functions->expects($this->once())->method('ldap_search')->with($this->equalTo('my_ldap_resource'), $this->equalTo('ou=People,dc=kanboard,dc=local'), $this->equalTo('uid=my_user'), $this->equalTo(array('displayname')))->will($this->returnValue('search_resource')); self::$functions->expects($this->once())->method('ldap_get_entries')->with($this->equalTo('my_ldap_resource'), $this->equalTo('search_resource'))->will($this->returnValue($entries)); $query = new Query(); $query->execute('my_ldap_resource', 'ou=People,dc=kanboard,dc=local', 'uid=my_user', array('displayname')); $this->assertTrue($query->hasResult()); $this->assertEquals('My user', $query->getAttributeValue('displayname')); $this->assertEquals('user1@localhost', $query->getAttributeValue('mail')); $this->assertEquals('', $query->getAttributeValue('not_found')); $this->assertEquals('uid=my_user,ou=People,dc=kanboard,dc=local', $query->getAttribute('dn')); $this->assertEquals(null, $query->getAttribute('missing')); }
/** * Build user profile * * @access private * @return boolean|array */ private function prepareProfile() { return array('ldap_id' => $this->query->getAttribute('dn', ''), 'username' => $this->query->getAttributeValue($this->getAttributeUsername()), 'name' => $this->query->getAttributeValue($this->getAttributeName()), 'email' => $this->query->getAttributeValue($this->getAttributeEmail()), 'is_admin' => (int) $this->isMemberOf($this->query->getAttribute($this->getAttributeGroup(), array()), $this->getGroupAdminDn()), 'is_project_admin' => (int) $this->isMemberOf($this->query->getAttribute($this->getAttributeGroup(), array()), $this->getGroupProjectAdminDn()), 'is_ldap_user' => 1); }