ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 117 of file ilObjUserTest.php.

118 {
119 include_once("./Services/User/classes/class.ilObjUser.php");
120
121 $value = "";
122
123 // creation
124 $user = new ilObjUser();
125 $d = array(
126 "login" => "aatestuser2",
127 "passwd_type" => IL_PASSWD_PLAIN,
128 "passwd" => "password",
129 "gender" => "f",
130 "firstname" => "Heidi",
131 "lastname" => "Kabel",
132 "email" => "qwe@ty.de",
133 "ext_account" => "ext_"
134 );
135 $user->assignData($d);
136 $user->setActive(true);
137 $user->create();
138 $user->saveAsNew();
139 $user->setLanguage("de");
140 $user->writePrefs();
141 $id = $user->getId();
142
145 $ids = ilObjUser::_getUserIdsByEmail("qwe@ty.de");
146 //var_dump($ids);
147 if (is_array($ids) && count($ids) == 1 && $ids[0] == "aatestuser2") {
148 $value.= "email1-";
149 }
150 $uid = ilObjUser::getUserIdByEmail("qwe@ty.de");
151 if ($uid == $id) {
152 $value.= "email2-";
153 }
154
156 foreach ($acc as $k => $v) {
157 if ($k == $id && $v == "ext_kabel") {
158 $value.= "auth1-";
159 }
160 }
161
162 if (ilObjUser::_lookupAuthMode($id) == "cas") {
163 $value.= "auth2-";
164 }
165
166 if (ilObjUser::_checkExternalAuthAccount("cas", "ext_kabel") == "aatestuser2") {
167 $value.= "auth3-";
168 }
169
170 if (ilObjUser::_externalAccountExists("ext_kabel", "cas")) {
171 $value.= "auth4-";
172 }
173
175 $la = ilObjUser::_getLocalAccountsForEmail("qwe@ty.de");
176
181
182 // deletion
183 $user->delete();
184
185 $this->assertEquals(
186 "email1-email2-auth1-auth2-auth3-auth4-",
187 $value
188 );
189 }
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 _checkExternalAuthAccount($a_auth, $a_account, $tryFallback=true)
check whether external account and authentication method matches with a user
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 _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...
for( $i=6;$i< 13;$i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296
if(!array_key_exists('StateId', $_REQUEST)) $id

References $d, $id, 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 286 of file ilObjUserTest.php.

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

References $d, $id, 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 $user = new ilObjUser($i);
30 $user->delete();
31 }
32
33 $user = new ilObjUser();
34
35 // creation
36 $d = array(
37 "login" => "aatestuser",
38 "passwd_type" => IL_PASSWD_PLAIN,
39 "passwd" => "password",
40 "gender" => "m",
41 "firstname" => "Max",
42 "lastname" => "Mutzke",
43 "email" => "de@de.de",
44 "client_ip" => "1.2.3.4",
45 "ext_account" => "ext_mutzke"
46 );
47 $user->assignData($d);
48 $user->create();
49 $user->saveAsNew();
50 $user->setLanguage("no");
51 $user->writePrefs();
52 $id = $user->getId();
53 $value.= $user->getFirstname() . "-";
54
55 // update
56 $user->setFirstname("Maxi");
57 $user->update();
58 $value.= $user->getFirstname() . "-";
59
60 // other update methods
61 $user->refreshLogin();
62
63 // lookups
64 $value.= ilObjUser::_lookupEmail($id) . "-";
65 $value.= ilObjUser::_lookupGender($id) . "-";
66 $value.= ilObjUser::_lookupClientIP($id) . "-";
68 $value.= $n["lastname"] . "-";
70 $value.= ilObjUser::_lookupLogin($id) . "-";
72 $value.= ilObjUser::_lookupId("aatestuser") . "-";
74 $value.= ilObjUser::_lookupLanguage($id) . "-";
76 if (ilObjUser::_loginExists("aatestuser")) {
77 $value.= "le-";
78 }
79
80 // preferences...
81 $user->writePref("testpref", "pref1");
82 $value.= ilObjUser::_lookupPref($id, "testpref") . "-";
83 $user->deletePref("testpref");
84 if (ilObjUser::_lookupPref($id, "testpref") == "") {
85 $value.= "pref2" . "-";
86 }
87
88 // activation
89 $user->setActive(false);
91 $value.= "act1-";
92 }
93 $user->setActive(true);
95 $value.= "act2-";
96 }
99 $value.= "act3-";
100 }
101
102 // deletion
103 $user->delete();
104
105 $this->assertEquals(
106 "Max-Maxi-de@de.de-m-1.2.3.4-Mutzke-aatestuser-ext_mutzke-$id-no-le-" .
107 "pref1-pref2-act1-act2-act3-",
108 $value
109 );
110 }
$n
Definition: RandomTest.php:85
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.
$i
Definition: disco.tpl.php:19

References $d, $i, $id, $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 346 of file ilObjUserTest.php.

347 {
348 $value = "";
349
350 include_once("./Services/User/classes/class.ilObjUser.php");
351 ilObjUser::_getNumberOfUsersForStyle("default", "delos");
353 ilObjUser::_moveUsersToStyle("default", "delos", "default", "delos");
354
355 $this->assertEquals(
356 "",
357 $value
358 );
359 }
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 195 of file ilObjUserTest.php.

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

References $d, $id, and IL_PASSWD_PLAIN.

◆ testSearch()

ilObjUserTest::testSearch ( )

Search methods @group IL_Init.

Definition at line 251 of file ilObjUserTest.php.

252 {
253 include_once("./Services/User/classes/class.ilObjUser.php");
254
255 $value = "";
256
257 ilObjUser::searchUsers("test", 1, false, false);
258 ilObjUser::searchUsers("test", 0, true, false);
259 ilObjUser::searchUsers("test", 1, false, 1);
260 ilObjUser::searchUsers("test", 1, false, 2);
261 ilObjUser::searchUsers("test", 1, false, 3);
262 ilObjUser::searchUsers("test", 1, false, 4);
263 ilObjUser::searchUsers("test", 1, false, 5);
264 ilObjUser::searchUsers("test", 1, false, 6);
265 ilObjUser::searchUsers("test", 1, false, 7);
266
267 ilObjUser::_getAllUserData(array("lastname", "online_time"));
268 ilObjUser::_getAllUserData(array("lastname", "online_time"), 1);
269 ilObjUser::_getAllUserData(array("lastname", "online_time"), 2);
270 ilObjUser::_getAllUserData(array("lastname", "online_time"), 3);
271 ilObjUser::_getAllUserData(array("lastname", "online_time"), 4);
272 ilObjUser::_getAllUserData(array("lastname", "online_time"), 5);
273 ilObjUser::_getAllUserData(array("lastname", "online_time"), 6);
274 ilObjUser::_getAllUserData(array("lastname", "online_time"), 7);
275
276 $this->assertEquals(
277 "",
278 $value
279 );
280 }
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.
static _getAllUserData($a_fields=null, $active=-1)
STATIC METHOD get all user data.

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: