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

@group needsInstalledILIAS More...

+ Inheritance diagram for ilObjectTest:
+ Collaboration diagram for ilObjectTest:

Public Member Functions

 testCreationDeletion ()
 @group IL_Init More...
 
 testSetGetLookup ()
 @group IL_Init More...
 
 testTreeTrash ()
 @group IL_Init More...
 
 testObjectReference ()
 test object reference queries @group IL_Init More...
 

Protected Member Functions

 setUp ()
 

Protected Attributes

 $backupGlobals = FALSE
 

Detailed Description

@group needsInstalledILIAS

Definition at line 6 of file ilObjectTest.php.

Member Function Documentation

◆ setUp()

ilObjectTest::setUp ( )
protected

Definition at line 10 of file ilObjectTest.php.

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

◆ testCreationDeletion()

ilObjectTest::testCreationDeletion ( )

@group IL_Init

Definition at line 19 of file ilObjectTest.php.

20 {
21 $obj = new ilObject();
22 $obj->setType("xxx");
23 $obj->create();
24 $id = $obj->getId();
25
26 $obj2 = new ilObject();
27 $obj2->setType("xxx");
28 $obj2->create();
29 $id2 = $obj2->getId();
30
31 if ($id2 == ($id + 1))
32 {
33 $value.= "create1-";
34 }
35
36 if (ilObject::_exists($id))
37 {
38 $value.= "create2-";
39 }
40
41 $obj->delete();
42 $obj2->delete();
43
44 if (!ilObject::_exists($id))
45 {
46 $value.= "create3-";
47 }
48
49
50 $this->assertEquals("create1-create2-create3-", $value);
51 }
Class ilObject Basic functions for all objects.
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data@access public

References ilObject\_exists().

+ Here is the call graph for this function:

◆ testObjectReference()

ilObjectTest::testObjectReference ( )

test object reference queries @group IL_Init

Definition at line 268 of file ilObjectTest.php.

269 {
270 include_once './Services/Object/classes/class.ilObject.php';
271
272 $ref_ids = ilObject::_getAllReferences(1);
273 $bool = ilObject::_setDeletedDate(1);
276
277 $this->assertEquals($date, null);
278
279
280 }
static _resetDeletedDate($a_ref_id)
only called in ilObjectGUI::insertSavedNodes
static _setDeletedDate($a_ref_id)
only called in ilTree::saveSubTree
static _getAllReferences($a_id)
get all reference ids of object
static _lookupDeletedDate($a_ref_id)
only called in ilObjectGUI::insertSavedNodes

References ilObject\_getAllReferences(), ilObject\_lookupDeletedDate(), ilObject\_resetDeletedDate(), and ilObject\_setDeletedDate().

+ Here is the call graph for this function:

◆ testSetGetLookup()

ilObjectTest::testSetGetLookup ( )

@group IL_Init

Definition at line 56 of file ilObjectTest.php.

57 {
58 global $ilUser;
59
60 $obj = new ilObject();
61 $obj->setType(""); // otherwise type check will fail
62 $obj->setTitle("TestObject");
63 $obj->setDescription("TestDescription");
64 $obj->setImportId("imp_44");
65 $obj->create();
66 $obj->createReference();
67 $id = $obj->getId();
68 $ref_id = $obj->getRefId();
69 $obj = new ilObject($id, false);
70
71 if ($obj->getType() == "")
72 {
73 $value.= "sg1-";
74 }
75 if ($obj->getTitle() == "TestObject")
76 {
77 $value.= "sg2-";
78 }
79 if ($obj->getDescription() == "TestDescription")
80 {
81 $value.= "sg3-";
82 }
83 if ($obj->getImportId() == "imp_44")
84 {
85 $value.= "sg4-";
86 }
87 if ($obj->getOwner() == $ilUser->getId())
88 {
89 $value.= "sg5-";
90 }
91
92 $obj = new ilObject($ref_id);
93 if ($obj->getTitle() == "TestObject")
94 {
95 $value.= "sg6-";
96 }
97
98 if ($obj->getCreateDate() == ($lu = $obj->getLastUpdateDate()))
99 {
100 $value.= "sg7-";
101 }
102 $obj->setTitle("TestObject2");
103 sleep(2); // we want a different date here...
104 $obj->update();
105
106 $obj = new ilObject($ref_id);
107 if ($lu != ($lu2 = $obj->getLastUpdateDate()))
108 {
109 $value.= "up1-";
110 }
111 if ($obj->getTitle() == "TestObject2")
112 {
113 $value.= "up2-";
114 }
115
116 if ($id == ilObject::_lookupObjIdByImportId("imp_44"))
117 {
118 $value.= "lu1-";
119 }
120
122 {
123 $value.= "lu2-";
124 }
125
126 if (ilObject::_lookupTitle($id) == "TestObject2")
127 {
128 $value.= "lu3-";
129 }
130 if (ilObject::_lookupDescription($id) == "TestDescription")
131 {
132 $value.= "lu4-";
133 }
134 if (ilObject::_lookupLastUpdate($id) == $lu2)
135 {
136 $value.= "lu5-";
137 }
139 {
140 $value.= "lu6-";
141 }
142 if (ilObject::_lookupType($id) == "")
143 {
144 $value.= "lu7-";
145 }
147 {
148 $value.= "lu8-";
149 }
151 if (is_array($ar) && count($ar) == 1 && $ar[$ref_id] == $ref_id)
152 {
153 $value.= "lu9-";
154 }
155
156 $ids = ilObject::_getIdsForTitle("TestObject2");
157 foreach ($ids as $i)
158 {
159 if ($i == $id)
160 {
161 $value.= "lu10-";
162 }
163 }
164
165 $obs = ilObject::_getObjectsByType("usr");
166 foreach ($obs as $ob)
167 {
168 if ($ob["obj_id"] == $ilUser->getId())
169 {
170 $value.= "lu11-";
171 }
172 }
173
179 if ($d1 != $d2 && $d1 == $d3 && $d3 == null)
180 {
181 $value.= "dd1-";
182 }
183
184 $obj->delete();
185
186 $this->assertEquals("sg1-sg2-sg3-sg4-sg5-sg6-sg7-up1-up2-".
187 "lu1-lu2-lu3-lu4-lu5-lu6-lu7-lu8-lu9-lu10-lu11-dd1-", $value);
188 }
static _lookupOwnerName($a_owner_id)
lookup owner name for owner id
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
static _lookupObjectId($a_ref_id)
lookup object id
static _getObjectsByType($a_obj_type="", $a_owner="")
Get objects by type.
static _lookupDescription($a_id)
lookup object description
static _lookupObjIdByImportId($a_import_id)
static _lookupLastUpdate($a_id, $a_as_string=false)
lookup last update
static _lookupOwner($a_id)
lookup object owner
static _lookupType($a_id, $a_reference=false)
lookup object type
static _getIdsForTitle($title, $type='', $partialmatch=false)
$ref_id
Definition: sahs_server.php:39
$ilUser
Definition: imgupload.php:18

References $ilUser, $ref_id, ilObject\_getAllReferences(), ilObject\_getIdsForTitle(), ilObject\_getObjectsByType(), ilObject\_lookupDeletedDate(), ilObject\_lookupDescription(), ilObject\_lookupLastUpdate(), ilObject\_lookupObjectId(), ilObject\_lookupObjId(), ilObject\_lookupObjIdByImportId(), ilObject\_lookupOwner(), ilObject\_lookupOwnerName(), ilObject\_lookupTitle(), ilObject\_lookupType(), ilObject\_resetDeletedDate(), and ilObject\_setDeletedDate().

+ Here is the call graph for this function:

◆ testTreeTrash()

ilObjectTest::testTreeTrash ( )

@group IL_Init

Definition at line 193 of file ilObjectTest.php.

194 {
195 global $tree;
196
197 $obj = new ilObject();
198 $obj->setType("xxx");
199 $obj->setTitle("TestObject");
200 $obj->setDescription("TestDescription");
201 $obj->setImportId("imp_44");
202 $obj->create();
203 $obj->createReference();
204 $id = $obj->getId();
205 $ref_id = $obj->getRefId();
206 $obj = new ilObject($ref_id);
207
208 $obj->putInTree(ROOT_FOLDER_ID);
209 $obj->setPermissions(ROOT_FOLDER_ID);
210 if ($tree->isInTree($ref_id))
211 {
212 $value.= "tree1-";
213 }
215 {
216 $value.= "tree2-";
217 }
218
219 // isSaved() uses internal cache!
220 $tree->useCache(false);
221
222 $tree->saveSubTree($ref_id, true);
223 if ($tree->isDeleted($ref_id))
224 {
225 $value.= "tree3-";
226 }
227 if ($tree->isSaved($ref_id))
228 {
229 $value.= "tree4-";
230 }
232 {
233 $value.= "tree5-";
234 }
236 {
237 $value.= "tree6-";
238 }
239
240 $saved_tree = new ilTree(-(int)$ref_id);
241 $node_data = $saved_tree->getNodeData($ref_id);
242 $saved_tree->deleteTree($node_data);
243
245 {
246 $value.= "tree7-";
247 }
248
249 $obs = ilUtil::_getObjectsByOperations("cat","read");
250 foreach ($obs as $ob)
251 {
253 {
254 $value.= "nocat-";
255 }
256 }
257
258 $obj->delete();
259
260 $this->assertEquals("tree1-tree2-tree3-tree4-tree5-tree6-tree7-", $value);
261
262 }
static _hasUntrashedReference($a_obj_id)
checks wether an object has at least one reference that is not in trash
static _isInTrash($a_ref_id)
checks wether object is in trash
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
static _getObjectsByOperations($a_obj_type, $a_operation, $a_usr_id=0, $limit=0)
Get all objects of a specific type and check access This function is not recursive,...

References $ref_id, ilUtil\_getObjectsByOperations(), ilObject\_hasUntrashedReference(), ilObject\_isInTrash(), ilObject\_lookupObjId(), and ilObject\_lookupType().

+ Here is the call graph for this function:

Field Documentation

◆ $backupGlobals

ilObjectTest::$backupGlobals = FALSE
protected

Definition at line 8 of file ilObjectTest.php.


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