ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 $logins = ilObjUser::getUserLoginsByEmail("qwe@ty.de");
146 //var_dump($ids);
147 if (is_array($logins) && count($logins) == 1 && $logins[0] == "aatestuser2") {
148 $value .= "email1-";
149 $uid = ilObjUser::getUserIdByLogin($logins[0]);
150 } else {
151 $uid = 0;
152 }
153
154 if ($uid == $id) {
155 $value .= "email2-";
156 }
157
159 foreach ($acc as $k => $v) {
160 if ($k == $id && $v == "ext_kabel") {
161 $value .= "auth1-";
162 }
163 }
164
165 if (ilObjUser::_lookupAuthMode($id) == "cas") {
166 $value .= "auth2-";
167 }
168
169 if (ilObjUser::_checkExternalAuthAccount("cas", "ext_kabel") == "aatestuser2") {
170 $value .= "auth3-";
171 }
172
173 if (ilObjUser::_externalAccountExists("ext_kabel", "cas")) {
174 $value .= "auth4-";
175 }
176
178 $la = ilObjUser::_getLocalAccountsForEmail("qwe@ty.de");
179
184
185 // deletion
186 $user->delete();
187
188 $this->assertEquals(
189 "email1-email2-auth1-auth2-auth3-auth4-",
190 $value
191 );
192 }
const IL_PASSWD_PLAIN
static _resetLoginAttempts($a_usr_id)
static _writeExternalAccount($a_usr_id, $a_ext_id)
static _checkExternalAuthAccount($a_auth, $a_account, $tryFallback=true)
check whether external account and authentication method matches with a user
static getUserIdByLogin($a_login)
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 _getLocalAccountsForEmail($a_email)
check whether external account and authentication method matches with a user
static getUserLoginsByEmail($a_email)
get all user login names of an email address
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
$user
Definition: migrateto20.php:57

References $d, $id, $user, ilObjUser\_checkExternalAuthAccount(), ilObjUser\_externalAccountExists(), ilObjUser\_getExternalAccountsByAuthMode(), ilObjUser\_getLocalAccountsForEmail(), ilObjUser\_getLoginAttempts(), ilObjUser\_getNumberOfUsersPerAuthMode(), ilObjUser\_incrementLoginAttempts(), ilObjUser\_lookupAuthMode(), ilObjUser\_resetLoginAttempts(), ilObjUser\_setUserInactive(), ilObjUser\_writeAuthMode(), ilObjUser\_writeExternalAccount(), ilObjUser\getUserIdByLogin(), ilObjUser\getUserLoginsByEmail(), and IL_PASSWD_PLAIN.

+ Here is the call graph for this function:

◆ testClipboard()

ilObjUserTest::testClipboard ( )

Clipboard @group IL_Init.

Definition at line 289 of file ilObjUserTest.php.

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

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

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

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

References $d, $id, $user, and IL_PASSWD_PLAIN.

◆ testSearch()

ilObjUserTest::testSearch ( )

Search methods @group IL_Init.

Definition at line 254 of file ilObjUserTest.php.

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