ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilObjectTest Class Reference
+ 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

Definition at line 4 of file ilObjectTest.php.

Member Function Documentation

◆ setUp()

ilObjectTest::setUp ( )
protected

Definition at line 8 of file ilObjectTest.php.

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

◆ testCreationDeletion()

ilObjectTest::testCreationDeletion ( )

@group IL_Init

Definition at line 17 of file ilObjectTest.php.

18 {
19 $obj = new ilObject();
20 $obj->setType("xxx");
21 $obj->create();
22 $id = $obj->getId();
23
24 $obj2 = new ilObject();
25 $obj2->setType("xxx");
26 $obj2->create();
27 $id2 = $obj2->getId();
28
29 if ($id2 == ($id + 1))
30 {
31 $value.= "create1-";
32 }
33
34 if (ilObject::_exists($id))
35 {
36 $value.= "create2-";
37 }
38
39 $obj->delete();
40 $obj2->delete();
41
42 if (!ilObject::_exists($id))
43 {
44 $value.= "create3-";
45 }
46
47
48 $this->assertEquals("create1-create2-create3-", $value);
49 }
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 266 of file ilObjectTest.php.

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

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 54 of file ilObjectTest.php.

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

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 191 of file ilObjectTest.php.

192 {
193 global $tree;
194
195 $obj = new ilObject();
196 $obj->setType("xxx");
197 $obj->setTitle("TestObject");
198 $obj->setDescription("TestDescription");
199 $obj->setImportId("imp_44");
200 $obj->create();
201 $obj->createReference();
202 $id = $obj->getId();
203 $ref_id = $obj->getRefId();
204 $obj = new ilObject($ref_id);
205
206 $obj->putInTree(ROOT_FOLDER_ID);
207 $obj->setPermissions(ROOT_FOLDER_ID);
208 if ($tree->isInTree($ref_id))
209 {
210 $value.= "tree1-";
211 }
213 {
214 $value.= "tree2-";
215 }
216
217 // isSaved() uses internal cache!
218 $tree->useCache(false);
219
220 $tree->saveSubTree($ref_id, true);
221 if ($tree->isDeleted($ref_id))
222 {
223 $value.= "tree3-";
224 }
225 if ($tree->isSaved($ref_id))
226 {
227 $value.= "tree4-";
228 }
230 {
231 $value.= "tree5-";
232 }
234 {
235 $value.= "tree6-";
236 }
237
238 $saved_tree = new ilTree(-(int)$ref_id);
239 $node_data = $saved_tree->getNodeData($ref_id);
240 $saved_tree->deleteTree($node_data);
241
243 {
244 $value.= "tree7-";
245 }
246
247 $obs = ilUtil::_getObjectsByOperations("cat","read");
248 foreach ($obs as $ob)
249 {
251 {
252 $value.= "nocat-";
253 }
254 }
255
256 $obj->delete();
257
258 $this->assertEquals("tree1-tree2-tree3-tree4-tree5-tree6-tree7-", $value);
259
260 }
_isInTrash($a_ref_id)
checks wether object is in trash
_hasUntrashedReference($a_obj_id)
checks wether an object has at least one reference that is not 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 6 of file ilObjectTest.php.


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