ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
ilObjectTest Class Reference
+ Inheritance diagram for ilObjectTest:
+ Collaboration diagram for ilObjectTest:

Public Member Functions

 testCreationDeletion ()
 IL_Init More...
 
 testSetGetLookup ()
 IL_Init More...
 
 testTreeTrash ()
 IL_Init More...
 
 testObjectReference ()
 test object reference queries 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 ( )

IL_Init

Definition at line 17 of file ilObjectTest.php.

References ilObject\_exists().

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  }
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
Class ilObject Basic functions for all objects.
+ Here is the call graph for this function:

◆ testObjectReference()

ilObjectTest::testObjectReference ( )

test object reference queries IL_Init

Definition at line 266 of file ilObjectTest.php.

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

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

◆ testSetGetLookup()

ilObjectTest::testSetGetLookup ( )

IL_Init

Definition at line 54 of file ilObjectTest.php.

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().

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 
119  if ($ilUser->getFullname() == ilObject::_lookupOwnerName(ilObject::_lookupOwner($id)))
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  }
136  if (ilObject::_lookupObjId($ref_id) == $id)
137  {
138  $value.= "lu6-";
139  }
140  if (ilObject::_lookupType($id) == "")
141  {
142  $value.= "lu7-";
143  }
145  {
146  $value.= "lu8-";
147  }
148  $ar = ilObject::_getAllReferences($id);
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  }
_resetDeletedDate($a_ref_id)
only called in ilObjectGUI::insertSavedNodes
_lookupOwner($a_id)
lookup object owner
Class ilObject Basic functions for all objects.
static _lookupTitle($a_id)
lookup object title
static _getObjectsByType($a_obj_type="", $a_owner="")
Get objects by type.
_setDeletedDate($a_ref_id)
only called in ilTree::saveSubTree
static _getAllReferences($a_id)
get all reference ids of object
static _lookupObjectId($a_ref_id)
lookup object id
_lookupOwnerName($a_owner_id)
lookup owner name for owner id
_lookupDeletedDate($a_ref_id)
only called in ilObjectGUI::insertSavedNodes
static _lookupDescription($a_id)
lookup object description
static _lookupObjId($a_id)
static _lookupType($a_id, $a_reference=false)
lookup object type
_lookupLastUpdate($a_id, $a_as_string=false)
lookup last update
global $ilUser
Definition: imgupload.php:15
$ref_id
Definition: sahs_server.php:39
static _getIdsForTitle($title, $type='', $partialmatch=false)
static _lookupObjIdByImportId($a_import_id)
+ Here is the call graph for this function:

◆ testTreeTrash()

ilObjectTest::testTreeTrash ( )

IL_Init

Definition at line 191 of file ilObjectTest.php.

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

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  }
Class ilObject Basic functions for all objects.
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, instead it parses the serialized rbac_pa entries.
static _lookupObjId($a_id)
_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 _lookupType($a_id, $a_reference=false)
lookup object type
_hasUntrashedReference($a_obj_id)
checks wether an object has at least one reference that is not in trash
$ref_id
Definition: sahs_server.php:39
+ 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: