ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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...
 
 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 10 of file ilObjUserTest.php.

Member Function Documentation

◆ setUp()

ilObjUserTest::setUp ( )
protected

Definition at line 14 of file ilObjUserTest.php.

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

◆ testAuthAndEmailMethods()

ilObjUserTest::testAuthAndEmailMethods ( )

Auth and email related methods @group IL_Init.

Definition at line 119 of file ilObjUserTest.php.

120 {
121 include_once("./Services/User/classes/class.ilObjUser.php");
122
123 $value = "";
124
125 // creation
126 $user = new ilObjUser();
127 $d = array(
128 "login" => "aatestuser2",
129 "passwd_type" => IL_PASSWD_PLAIN,
130 "passwd" => "password",
131 "gender" => "f",
132 "firstname" => "Heidi",
133 "lastname" => "Kabel",
134 "email" => "qwe@ty.de",
135 "ext_account" => "ext_"
136 );
137 $user->assignData($d);
138 $user->setActive(true);
139 $user->create();
140 $user->saveAsNew();
141 $user->setLanguage("de");
142 $user->writePrefs();
143 $id = $user->getId();
144
145 ilObjUser::_writeExternalAccount($id, "ext_kabel");
146 ilObjUser::_writeAuthMode($id, "cas");
147 $logins = ilObjUser::getUserLoginsByEmail("qwe@ty.de");
148 //var_dump($ids);
149 if (is_array($logins) && count($logins) == 1 && $logins[0] == "aatestuser2") {
150 $value .= "email1-";
151 $uid = ilObjUser::getUserIdByLogin($logins[0]);
152 } else {
153 $uid = 0;
154 }
155
156 if ($uid == $id) {
157 $value .= "email2-";
158 }
159
161 foreach ($acc as $k => $v) {
162 if ($k == $id && $v == "ext_kabel") {
163 $value .= "auth1-";
164 }
165 }
166
167 if (ilObjUser::_lookupAuthMode($id) == "cas") {
168 $value .= "auth2-";
169 }
170
171 if (ilObjUser::_checkExternalAuthAccount("cas", "ext_kabel") == "aatestuser2") {
172 $value .= "auth3-";
173 }
174
175 if (ilObjUser::_externalAccountExists("ext_kabel", "cas")) {
176 $value .= "auth4-";
177 }
178
180 $la = ilObjUser::_getLocalAccountsForEmail("qwe@ty.de");
181
186
187 // deletion
188 $user->delete();
189
190 $this->assertEquals(
191 "email1-email2-auth1-auth2-auth3-auth4-",
192 $value
193 );
194 }
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

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

237 {
238 $value = "";
239
240 // creation
241 $user = new ilObjUser();
242 $d = array(
243 "login" => "aatestuser3",
244 "passwd_type" => IL_PASSWD_PLAIN,
245 "passwd" => "password",
246 "gender" => "f",
247 "firstname" => "Heidi",
248 "lastname" => "Kabel",
249 "email" => "de@de.de"
250 );
251 $user->assignData($d);
252 $user->setActive(true);
253 $user->create();
254 $user->saveAsNew();
255 $user->setLanguage("de");
256 $user->writePrefs();
257 $id = $user->getId();
258
259 $user->addObjectToClipboard($id, "user", "aatestuser");
260 $user->addObjectToClipboard(56, "mump", "mumpitz");
261 if ($user->clipboardHasObjectsOfType("user")) {
262 $value .= "clip1-";
263 }
264
265 $user->clipboardDeleteObjectsOfType("user");
266 if ($user->clipboardHasObjectsOfType("mump") &&
267 !$user->clipboardHasObjectsOfType("user")) {
268 $value .= "clip2-";
269 }
270
271 $objs = $user->getClipboardObjects("mump");
272 if (is_array($objs) && count($objs) == 1 && $objs[0]["id"] == 56) {
273 $value .= "clip3-";
274 }
275
276 $objs = $user->getClipboardChilds(56, "2008-10-10");
277
279
280 if (is_array($us) && count($us) == 1 && $us[0] == $id) {
281 $value .= "clip4-";
282 }
283
284 $user->delete();
285
286 $this->assertEquals(
287 "clip1-clip2-clip3-clip4-",
288 $value
289 );
290 }
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 24 of file ilObjUserTest.php.

25 {
26 include_once("./Services/User/classes/class.ilObjUser.php");
27
28
29 // delete all aatestuser from previous runs
30 while (($i = ilObjUser::_lookupId("aatestuser")) > 0) {
31 $user = new ilObjUser($i);
32 $user->delete();
33 }
34
35 $user = new ilObjUser();
36
37 // creation
38 $d = array(
39 "login" => "aatestuser",
40 "passwd_type" => IL_PASSWD_PLAIN,
41 "passwd" => "password",
42 "gender" => "m",
43 "firstname" => "Max",
44 "lastname" => "Mutzke",
45 "email" => "de@de.de",
46 "client_ip" => "1.2.3.4",
47 "ext_account" => "ext_mutzke"
48 );
49 $user->assignData($d);
50 $user->create();
51 $user->saveAsNew();
52 $user->setLanguage("no");
53 $user->writePrefs();
54 $id = $user->getId();
55 $value .= $user->getFirstname() . "-";
56
57 // update
58 $user->setFirstname("Maxi");
59 $user->update();
60 $value .= $user->getFirstname() . "-";
61
62 // other update methods
63 $user->refreshLogin();
64
65 // lookups
66 $value .= ilObjUser::_lookupEmail($id) . "-";
67 $value .= ilObjUser::_lookupGender($id) . "-";
68 $value .= ilObjUser::_lookupClientIP($id) . "-";
70 $value .= $n["lastname"] . "-";
72 $value .= ilObjUser::_lookupLogin($id) . "-";
73 $value .= ilObjUser::_lookupExternalAccount($id) . "-";
74 $value .= ilObjUser::_lookupId("aatestuser") . "-";
76 $value .= ilObjUser::_lookupLanguage($id) . "-";
78 if (ilObjUser::_loginExists("aatestuser")) {
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 $value .= "pref2" . "-";
88 }
89
90 // activation
91 $user->setActive(false);
93 $value .= "act1-";
94 }
95 $user->setActive(true);
97 $value .= "act2-";
98 }
100 if (!ilObjUser::getStoredActive($id)) {
101 $value .= "act3-";
102 }
103
104 // deletion
105 $user->delete();
106
107 $this->assertEquals(
108 "Max-Maxi-de@de.de-m-1.2.3.4-Mutzke-aatestuser-ext_mutzke-$id-no-le-" .
109 "pref1-pref2-act1-act2-act3-",
110 $value
111 );
112 }
$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: metadata.php:24

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

297 {
298 $value = "";
299
300 include_once("./Services/User/classes/class.ilObjUser.php");
301 ilObjUser::_getNumberOfUsersForStyle("default", "delos");
303 ilObjUser::_moveUsersToStyle("default", "delos", "default", "delos");
304
305 $this->assertEquals(
306 "",
307 $value
308 );
309 }
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:

◆ testSearch()

ilObjUserTest::testSearch ( )

Search methods @group IL_Init.

Definition at line 201 of file ilObjUserTest.php.

202 {
203 include_once("./Services/User/classes/class.ilObjUser.php");
204
205 $value = "";
206
207 ilObjUser::searchUsers("test", 1, false, false);
208 ilObjUser::searchUsers("test", 0, true, false);
209 ilObjUser::searchUsers("test", 1, false, 1);
210 ilObjUser::searchUsers("test", 1, false, 2);
211 ilObjUser::searchUsers("test", 1, false, 3);
212 ilObjUser::searchUsers("test", 1, false, 4);
213 ilObjUser::searchUsers("test", 1, false, 5);
214 ilObjUser::searchUsers("test", 1, false, 6);
215 ilObjUser::searchUsers("test", 1, false, 7);
216
217 ilObjUser::_getAllUserData(array("lastname", "online_time"));
218 ilObjUser::_getAllUserData(array("lastname", "online_time"), 1);
219 ilObjUser::_getAllUserData(array("lastname", "online_time"), 2);
220 ilObjUser::_getAllUserData(array("lastname", "online_time"), 3);
221 ilObjUser::_getAllUserData(array("lastname", "online_time"), 4);
222 ilObjUser::_getAllUserData(array("lastname", "online_time"), 5);
223 ilObjUser::_getAllUserData(array("lastname", "online_time"), 6);
224 ilObjUser::_getAllUserData(array("lastname", "online_time"), 7);
225
226 $this->assertEquals(
227 "",
228 $value
229 );
230 }
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 12 of file ilObjUserTest.php.


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