ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilObjUserTest Class Reference

Class ilObjUserTest @group needsInstalledILIAS. More...

+ Inheritance diagram for ilObjUserTest:
+ Collaboration diagram for ilObjUserTest:

Public Member Functions

 testCreateSetLookupDelete ()
 Creates a user, sets preferences, lookups data, delete user @group IL_Init. More...
 
 testAuthAndEmailMethods ()
 Auth and email related methods @group IL_Init. More...
 
 testPersonalDesktopItems ()
 Personal Desktop Items @group IL_Init. More...
 
 testSearch ()
 Search methods @group IL_Init. More...
 
 testClipboard ()
 Clipboard @group IL_Init. More...
 
 testMiscellaneous ()
 Miscellaneous @group IL_Init. More...
 

Protected Member Functions

 setUp ()
 

Protected Attributes

 $backupGlobals = FALSE
 

Detailed Description

Class ilObjUserTest @group needsInstalledILIAS.

Definition at line 8 of file ilObjUserTest.php.

Member Function Documentation

◆ setUp()

ilObjUserTest::setUp ( )
protected

Definition at line 12 of file ilObjUserTest.php.

13 {
14 include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
15 ilUnitUtil::performInitialisation();
16 }

◆ testAuthAndEmailMethods()

ilObjUserTest::testAuthAndEmailMethods ( )

Auth and email related methods @group IL_Init.

Definition at line 121 of file ilObjUserTest.php.

122 {
123 include_once("./Services/User/classes/class.ilObjUser.php");
124
125 $value = "";
126
127 // creation
128 $user = new ilObjUser();
129 $d = array(
130 "login" => "aatestuser2",
131 "passwd_type" => IL_PASSWD_PLAIN,
132 "passwd" => "password",
133 "gender" => "f",
134 "firstname" => "Heidi",
135 "lastname" => "Kabel",
136 "email" => "qwe@ty.de",
137 "ext_account" => "ext_"
138 );
139 $user->assignData($d);
140 $user->setActive(true);
141 $user->create();
142 $user->saveAsNew();
143 $user->setLanguage("de");
144 $user->writePrefs();
145 $id = $user->getId();
146
147 ilObjUser::_writeExternalAccount($id, "ext_kabel");
148 ilObjUser::_writeAuthMode($id, "cas");
149 $ids = ilObjUser::_getUserIdsByEmail("qwe@ty.de");
150//var_dump($ids);
151 if (is_array($ids) && count($ids) == 1 && $ids[0] == "aatestuser2")
152 {
153 $value.= "email1-";
154 }
155 $uid = ilObjUser::getUserIdByEmail("qwe@ty.de");
156 if ($uid == $id)
157 {
158 $value.= "email2-";
159 }
160
162 foreach ($acc as $k => $v)
163 if ($k == $id && $v == "ext_kabel")
164 {
165 $value.= "auth1-";
166 }
167
168 if (ilObjUser::_lookupAuthMode($id) == "cas")
169 {
170 $value.= "auth2-";
171 }
172
173 if (ilObjUser::_checkExternalAuthAccount("cas", "ext_kabel") == "aatestuser2")
174 {
175 $value.= "auth3-";
176 }
177
178 if (ilObjUser::_externalAccountExists("ext_kabel","cas"))
179 {
180 $value.= "auth4-";
181 }
182
184 $la = ilObjUser::_getLocalAccountsForEmail("qwe@ty.de");
185
190
191 // deletion
192 $user->delete();
193
194 $this->assertEquals("email1-email2-auth1-auth2-auth3-auth4-",
195 $value);
196 }
for($col=0; $col< 50; $col++) $d
const IL_PASSWD_PLAIN
static _resetLoginAttempts($a_usr_id)
static _writeExternalAccount($a_usr_id, $a_ext_id)
getUserIdByEmail($a_email)
STATIC METHOD get the user_id of an email address.
static _writeAuthMode($a_usr_id, $a_auth_mode)
static _incrementLoginAttempts($a_usr_id)
static _getNumberOfUsersPerAuthMode()
get number of users per auth mode
static _externalAccountExists($a_external_account, $a_auth_mode)
Check if an external account name already exists.
static _setUserInactive($a_usr_id)
static _lookupAuthMode($a_usr_id)
lookup auth mode
static _getLoginAttempts($a_usr_id)
static _getUserIdsByEmail($a_email)
STATIC METHOD get all user_ids of an email address.
static _getLocalAccountsForEmail($a_email)
check whether external account and authentication method matches with a user
static _checkExternalAuthAccount($a_auth, $a_account)
check whether external account and authentication method matches with a user
static _getExternalAccountsByAuthMode($a_auth_mode, $a_read_auth_default=false)
Get list of external account by authentication method Note: If login == ext_account for two user with...

References $d, ilObjUser\_checkExternalAuthAccount(), ilObjUser\_externalAccountExists(), ilObjUser\_getExternalAccountsByAuthMode(), ilObjUser\_getLocalAccountsForEmail(), ilObjUser\_getLoginAttempts(), ilObjUser\_getNumberOfUsersPerAuthMode(), ilObjUser\_getUserIdsByEmail(), ilObjUser\_incrementLoginAttempts(), ilObjUser\_lookupAuthMode(), ilObjUser\_resetLoginAttempts(), ilObjUser\_setUserInactive(), ilObjUser\_writeAuthMode(), ilObjUser\_writeExternalAccount(), ilObjUser\getUserIdByEmail(), and IL_PASSWD_PLAIN.

+ Here is the call graph for this function:

◆ testClipboard()

ilObjUserTest::testClipboard ( )

Clipboard @group IL_Init.

Definition at line 293 of file ilObjUserTest.php.

294 {
295 $value = "";
296
297 // creation
298 $user = new ilObjUser();
299 $d = array(
300 "login" => "aatestuser3",
301 "passwd_type" => IL_PASSWD_PLAIN,
302 "passwd" => "password",
303 "gender" => "f",
304 "firstname" => "Heidi",
305 "lastname" => "Kabel",
306 "email" => "de@de.de"
307 );
308 $user->assignData($d);
309 $user->setActive(true);
310 $user->create();
311 $user->saveAsNew();
312 $user->setLanguage("de");
313 $user->writePrefs();
314 $id = $user->getId();
315
316 $user->addObjectToClipboard($id, "user", "aatestuser");
317 $user->addObjectToClipboard(56, "mump", "mumpitz");
318 if ($user->clipboardHasObjectsOfType("user"))
319 {
320 $value.= "clip1-";
321 }
322
323 $user->clipboardDeleteObjectsOfType("user");
324 if ($user->clipboardHasObjectsOfType("mump") &&
325 !$user->clipboardHasObjectsOfType("user"))
326 {
327 $value.= "clip2-";
328 }
329
330 $objs = $user->getClipboardObjects("mump");
331 if (is_array($objs) && count($objs) == 1 && $objs[0]["id"] == 56)
332 {
333 $value.= "clip3-";
334 }
335
336 $objs = $user->getClipboardChilds(56, "2008-10-10");
337
339
340 if (is_array($us) && count($us) == 1 && $us[0] == $id)
341 {
342 $value.= "clip4-";
343 }
344
345 $user->delete();
346
347 $this->assertEquals("clip1-clip2-clip3-clip4-",
348 $value);
349 }
static _getUsersForClipboadObject($a_type, $a_id)
get all users, that have a certain object within their clipboard

References $d, ilObjUser\_getUsersForClipboadObject(), and IL_PASSWD_PLAIN.

+ Here is the call graph for this function:

◆ testCreateSetLookupDelete()

ilObjUserTest::testCreateSetLookupDelete ( )

Creates a user, sets preferences, lookups data, delete user @group IL_Init.

Definition at line 22 of file ilObjUserTest.php.

23 {
24 include_once("./Services/User/classes/class.ilObjUser.php");
25
26
27 // delete all aatestuser from previous runs
28 while (($i = ilObjUser::_lookupId("aatestuser")) > 0)
29 {
30 $user = new ilObjUser($i);
31 $user->delete();
32 }
33
34 $user = new ilObjUser();
35
36 // creation
37 $d = array(
38 "login" => "aatestuser",
39 "passwd_type" => IL_PASSWD_PLAIN,
40 "passwd" => "password",
41 "gender" => "m",
42 "firstname" => "Max",
43 "lastname" => "Mutzke",
44 "email" => "de@de.de",
45 "client_ip" => "1.2.3.4",
46 "ext_account" => "ext_mutzke"
47 );
48 $user->assignData($d);
49 $user->create();
50 $user->saveAsNew();
51 $user->setLanguage("no");
52 $user->writePrefs();
53 $id = $user->getId();
54 $value.= $user->getFirstname()."-";
55
56 // update
57 $user->setFirstname("Maxi");
58 $user->update();
59 $value.= $user->getFirstname()."-";
60
61 // other update methods
62 $user->refreshLogin();
63
64 // lookups
65 $value.= ilObjUser::_lookupEmail($id)."-";
66 $value.= ilObjUser::_lookupGender($id)."-";
67 $value.= ilObjUser::_lookupClientIP($id)."-";
69 $value.= $n["lastname"]."-";
71 $value.= ilObjUser::_lookupLogin($id)."-";
72 $value.= ilObjUser::_lookupExternalAccount($id)."-";
73 $value.= ilObjUser::_lookupId("aatestuser")."-";
75 $value.= ilObjUser::_lookupLanguage($id)."-";
77 if (ilObjUser::_loginExists("aatestuser"))
78 {
79 $value.= "le-";
80 }
81
82 // preferences...
83 $user->writePref("testpref", "pref1");
84 $value.= ilObjUser::_lookupPref($id, "testpref")."-";
85 $user->deletePref("testpref");
86 if (ilObjUser::_lookupPref($id, "testpref") == "")
87 {
88 $value.= "pref2"."-";
89 }
90
91 // activation
92 $user->setActive(false);
94 {
95 $value.= "act1-";
96 }
97 $user->setActive(true);
99 {
100 $value.= "act2-";
101 }
102 ilObjUser::_toggleActiveStatusOfUsers(array($id), false);
104 {
105 $value.= "act3-";
106 }
107
108 // deletion
109 $user->delete();
110
111 $this->assertEquals("Max-Maxi-de@de.de-m-1.2.3.4-Mutzke-aatestuser-ext_mutzke-$id-no-le-".
112 "pref1-pref2-act1-act2-act3-",
113 $value);
114 }
$n
Definition: RandomTest.php:80
static _lookupPref($a_usr_id, $a_keyword)
static _lookupEmail($a_user_id)
Lookup email.
static _lookupFields($a_user_id)
lookup fields (deprecated; use more specific methods instead)
static _lookupLogin($a_user_id)
lookup login
static _lookupExternalAccount($a_user_id)
lookup external account for login and authmethod
static _lookupId($a_user_str)
Lookup id by login.
static _lookupGender($a_user_id)
Lookup gender.
static _lookupName($a_user_id)
lookup user name
static _toggleActiveStatusOfUsers($a_usr_ids, $a_status)
Toggle active status of users.
static _readUsersProfileData($a_user_ids)
STATIC METHOD get user data of selected users.
getStoredActive($a_id)
get user active state
static _lookupLastLogin($a_user_id)
lookup last login
static _loginExists($a_login, $a_user_id=0)
check if a login name already exists You may exclude a user from the check by giving his user id as 2...
static _lookupLanguage($a_usr_id)
static _lookupClientIP($a_user_id)
Lookup client ip.

References $d, $n, ilObjUser\_loginExists(), ilObjUser\_lookupClientIP(), ilObjUser\_lookupEmail(), ilObjUser\_lookupExternalAccount(), ilObjUser\_lookupFields(), ilObjUser\_lookupGender(), ilObjUser\_lookupId(), ilObjUser\_lookupLanguage(), ilObjUser\_lookupLastLogin(), ilObjUser\_lookupLogin(), ilObjUser\_lookupName(), ilObjUser\_lookupPref(), ilObjUser\_readUsersProfileData(), ilObjUser\_toggleActiveStatusOfUsers(), ilObjUser\getStoredActive(), and IL_PASSWD_PLAIN.

+ Here is the call graph for this function:

◆ testMiscellaneous()

ilObjUserTest::testMiscellaneous ( )

Miscellaneous @group IL_Init.

Definition at line 355 of file ilObjUserTest.php.

356 {
357 $value = "";
358
359 include_once("./Services/User/classes/class.ilObjUser.php");
360 ilObjUser::_getNumberOfUsersForStyle("default", "delos");
362 ilObjUser::_moveUsersToStyle("default", "delos", "default", "delos");
363
364 $this->assertEquals("",
365 $value);
366 }
static _getAllUserAssignedStyles()
skins and styles
static _moveUsersToStyle($a_from_skin, $a_from_style, $a_to_skin, $a_to_style)
skins and styles
static _getNumberOfUsersForStyle($a_skin, $a_style)
skins and styles

References ilObjUser\_getAllUserAssignedStyles(), ilObjUser\_getNumberOfUsersForStyle(), and ilObjUser\_moveUsersToStyle().

+ Here is the call graph for this function:

◆ testPersonalDesktopItems()

ilObjUserTest::testPersonalDesktopItems ( )

Personal Desktop Items @group IL_Init.

Definition at line 202 of file ilObjUserTest.php.

203 {
204 include_once("./Services/User/classes/class.ilObjUser.php");
205
206 $value = "";
207
208 // creation
209 $user = new ilObjUser();
210 $d = array(
211 "login" => "aatestuser3",
212 "passwd_type" => IL_PASSWD_PLAIN,
213 "passwd" => "password",
214 "gender" => "f",
215 "firstname" => "Heidi",
216 "lastname" => "Kabel",
217 "email" => "de@de.de"
218 );
219 $user->assignData($d);
220 $user->setActive(true);
221 $user->create();
222 $user->saveAsNew();
223 $user->setLanguage("de");
224 $user->writePrefs();
225 $id = $user->getId();
226
227 $user->addDesktopItem(ROOT_FOLDER_ID, "root");
228 if ($user->isDesktopItem(ROOT_FOLDER_ID, "root"))
229 {
230 $value.= "desk1-";
231 }
232 $user->setDesktopItemParameters(ROOT_FOLDER_ID, "root", "par1");
233 $di = $user->getDesktopItems();
234 if ($item = current($di))
235 {
236 if ($item["type"] == "root" && $item["ref_id"] == ROOT_FOLDER_ID)
237 {
238 $value.= "desk2-";
239 }
240 }
241
242 $user->dropDesktopItem(ROOT_FOLDER_ID, "root");
243 if (!$user->isDesktopItem(ROOT_FOLDER_ID, "root"))
244 {
245 $value.= "desk3-";
246 }
247 $user->_removeItemFromDesktops(ROOT_FOLDER_ID);
248
249 // deletion
250 $user->delete();
251
252 $this->assertEquals("desk1-desk2-desk3-",
253 $value);
254 }

References $d, and IL_PASSWD_PLAIN.

◆ testSearch()

ilObjUserTest::testSearch ( )

Search methods @group IL_Init.

Definition at line 260 of file ilObjUserTest.php.

261 {
262 include_once("./Services/User/classes/class.ilObjUser.php");
263
264 $value = "";
265
266 ilObjUser::searchUsers("test", 1, false, false);
267 ilObjUser::searchUsers("test", 0, true, false);
268 ilObjUser::searchUsers("test", 1, false, 1);
269 ilObjUser::searchUsers("test", 1, false, 2);
270 ilObjUser::searchUsers("test", 1, false, 3);
271 ilObjUser::searchUsers("test", 1, false, 4);
272 ilObjUser::searchUsers("test", 1, false, 5);
273 ilObjUser::searchUsers("test", 1, false, 6);
274 ilObjUser::searchUsers("test", 1, false, 7);
275
276 ilObjUser::_getAllUserData(array("lastname", "online_time"));
277 ilObjUser::_getAllUserData(array("lastname", "online_time"), 1);
278 ilObjUser::_getAllUserData(array("lastname", "online_time"), 2);
279 ilObjUser::_getAllUserData(array("lastname", "online_time"), 3);
280 ilObjUser::_getAllUserData(array("lastname", "online_time"), 4);
281 ilObjUser::_getAllUserData(array("lastname", "online_time"), 5);
282 ilObjUser::_getAllUserData(array("lastname", "online_time"), 6);
283 ilObjUser::_getAllUserData(array("lastname", "online_time"), 7);
284
285 $this->assertEquals("",
286 $value);
287 }
static _getAllUserData($a_fields=NULL, $active=-1)
STATIC METHOD get all user data.
static searchUsers($a_search_str, $active=1, $a_return_ids_only=false, $filter_settings=FALSE)
STATIC METHOD get the user_ids which correspond a search string.

References ilObjUser\_getAllUserData(), and ilObjUser\searchUsers().

+ Here is the call graph for this function:

Field Documentation

◆ $backupGlobals

ilObjUserTest::$backupGlobals = FALSE
protected

Definition at line 10 of file ilObjUserTest.php.


The documentation for this class was generated from the following file: