ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilObjectTest Class Reference

needsInstalledILIAS More...

+ 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

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

IL_Init

Definition at line 19 of file ilObjectTest.php.

References $id, and ilObject\_exists().

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  $value.= "create1-";
33  }
34 
35  if (ilObject::_exists($id)) {
36  $value.= "create2-";
37  }
38 
39  $obj->delete();
40  $obj2->delete();
41 
42  if (!ilObject::_exists($id)) {
43  $value.= "create3-";
44  }
45 
46 
47  $this->assertEquals("create1-create2-create3-", $value);
48  }
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
if(!array_key_exists('StateId', $_REQUEST)) $id
+ Here is the call graph for this function:

◆ testObjectReference()

ilObjectTest::testObjectReference ( )

test object reference queries IL_Init

Definition at line 232 of file ilObjectTest.php.

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

233  {
234  include_once './Services/Object/classes/class.ilObject.php';
235 
236  $ref_ids = ilObject::_getAllReferences(1);
237  $bool = ilObject::_setDeletedDate(1);
238  $bool = ilObject::_resetDeletedDate(1);
239  $date = ilObject::_lookupDeletedDate(1);
240 
241  $this->assertEquals($date, null);
242  }
static _resetDeletedDate($a_ref_id)
only called in ilObjectGUI::insertSavedNodes
static _lookupDeletedDate($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
+ Here is the call graph for this function:

◆ testSetGetLookup()

ilObjectTest::testSetGetLookup ( )

IL_Init

Definition at line 53 of file ilObjectTest.php.

References $i, $id, $ilUser, 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().

54  {
55  global $ilUser;
56 
57  $obj = new ilObject();
58  $obj->setType(""); // otherwise type check will fail
59  $obj->setTitle("TestObject");
60  $obj->setDescription("TestDescription");
61  $obj->setImportId("imp_44");
62  $obj->create();
63  $obj->createReference();
64  $id = $obj->getId();
65  $ref_id = $obj->getRefId();
66  $obj = new ilObject($id, false);
67 
68  if ($obj->getType() == "") {
69  $value.= "sg1-";
70  }
71  if ($obj->getTitle() == "TestObject") {
72  $value.= "sg2-";
73  }
74  if ($obj->getDescription() == "TestDescription") {
75  $value.= "sg3-";
76  }
77  if ($obj->getImportId() == "imp_44") {
78  $value.= "sg4-";
79  }
80  if ($obj->getOwner() == $ilUser->getId()) {
81  $value.= "sg5-";
82  }
83 
84  $obj = new ilObject($ref_id);
85  if ($obj->getTitle() == "TestObject") {
86  $value.= "sg6-";
87  }
88 
89  if ($obj->getCreateDate() == ($lu = $obj->getLastUpdateDate())) {
90  $value.= "sg7-";
91  }
92  $obj->setTitle("TestObject2");
93  sleep(2); // we want a different date here...
94  $obj->update();
95 
96  $obj = new ilObject($ref_id);
97  if ($lu != ($lu2 = $obj->getLastUpdateDate())) {
98  $value.= "up1-";
99  }
100  if ($obj->getTitle() == "TestObject2") {
101  $value.= "up2-";
102  }
103 
104  if ($id == ilObject::_lookupObjIdByImportId("imp_44")) {
105  $value.= "lu1-";
106  }
107 
108  if ($ilUser->getFullname() == ilObject::_lookupOwnerName(ilObject::_lookupOwner($id))) {
109  $value.= "lu2-";
110  }
111 
112  if (ilObject::_lookupTitle($id) == "TestObject2") {
113  $value.= "lu3-";
114  }
115  if (ilObject::_lookupDescription($id) == "TestDescription") {
116  $value.= "lu4-";
117  }
118  if (ilObject::_lookupLastUpdate($id) == $lu2) {
119  $value.= "lu5-";
120  }
121  if (ilObject::_lookupObjId($ref_id) == $id) {
122  $value.= "lu6-";
123  }
124  if (ilObject::_lookupType($id) == "") {
125  $value.= "lu7-";
126  }
127  if (ilObject::_lookupObjectId($ref_id) == $id) {
128  $value.= "lu8-";
129  }
131  if (is_array($ar) && count($ar) == 1 && $ar[$ref_id] == $ref_id) {
132  $value.= "lu9-";
133  }
134 
135  $ids = ilObject::_getIdsForTitle("TestObject2");
136  foreach ($ids as $i) {
137  if ($i == $id) {
138  $value.= "lu10-";
139  }
140  }
141 
142  $obs = ilObject::_getObjectsByType("usr");
143  foreach ($obs as $ob) {
144  if ($ob["obj_id"] == $ilUser->getId()) {
145  $value.= "lu11-";
146  }
147  }
148 
149  $d1 = ilObject::_lookupDeletedDate($ref_id);
150  ilObject::_setDeletedDate($ref_id);
151  $d2 = ilObject::_lookupDeletedDate($ref_id);
153  $d3 = ilObject::_lookupDeletedDate($ref_id);
154  if ($d1 != $d2 && $d1 == $d3 && $d3 == null) {
155  $value.= "dd1-";
156  }
157 
158  $obj->delete();
159 
160  $this->assertEquals("sg1-sg2-sg3-sg4-sg5-sg6-sg7-up1-up2-" .
161  "lu1-lu2-lu3-lu4-lu5-lu6-lu7-lu8-lu9-lu10-lu11-dd1-", $value);
162  }
static _resetDeletedDate($a_ref_id)
only called in ilObjectGUI::insertSavedNodes
static _lookupDeletedDate($a_ref_id)
only called in ilObjectGUI::insertSavedNodes
if(!array_key_exists('StateId', $_REQUEST)) $id
static _lookupTitle($a_id)
lookup object title
static _getObjectsByType($a_obj_type="", $a_owner="")
Get objects by type.
static _setDeletedDate($a_ref_id)
only called in ilTree::saveSubTree
static _getAllReferences($a_id)
get all reference ids of object
static _lookupLastUpdate($a_id, $a_as_string=false)
lookup last update
static _lookupObjectId($a_ref_id)
lookup object id
static _lookupDescription($a_id)
lookup object description
static _lookupObjId($a_id)
$ilUser
Definition: imgupload.php:18
static _lookupOwner($a_id)
lookup object owner
static _lookupType($a_id, $a_reference=false)
lookup object type
$i
Definition: disco.tpl.php:19
static _getIdsForTitle($title, $type='', $partialmatch=false)
static _lookupOwnerName($a_owner_id)
lookup owner name for owner id
static _lookupObjIdByImportId($a_import_id)
+ Here is the call graph for this function:

◆ testTreeTrash()

ilObjectTest::testTreeTrash ( )

IL_Init

Definition at line 167 of file ilObjectTest.php.

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

168  {
169  global $tree;
170 
171  $obj = new ilObject();
172  $obj->setType("xxx");
173  $obj->setTitle("TestObject");
174  $obj->setDescription("TestDescription");
175  $obj->setImportId("imp_44");
176  $obj->create();
177  $obj->createReference();
178  $id = $obj->getId();
179  $ref_id = $obj->getRefId();
180  $obj = new ilObject($ref_id);
181 
182  $obj->putInTree(ROOT_FOLDER_ID);
183  $obj->setPermissions(ROOT_FOLDER_ID);
184  if ($tree->isInTree($ref_id)) {
185  $value.= "tree1-";
186  }
188  $value.= "tree2-";
189  }
190 
191  // isSaved() uses internal cache!
192  $tree->useCache(false);
193 
194  $tree->saveSubTree($ref_id, true);
195  if ($tree->isDeleted($ref_id)) {
196  $value.= "tree3-";
197  }
198  if ($tree->isSaved($ref_id)) {
199  $value.= "tree4-";
200  }
201  if (ilObject::_isInTrash($ref_id)) {
202  $value.= "tree5-";
203  }
205  $value.= "tree6-";
206  }
207 
208  $saved_tree = new ilTree(-(int) $ref_id);
209  $node_data = $saved_tree->getNodeData($ref_id);
210  $saved_tree->deleteTree($node_data);
211 
212  if (!ilObject::_isInTrash($ref_id)) {
213  $value.= "tree7-";
214  }
215 
216  $obs = ilUtil::_getObjectsByOperations("cat", "read");
217  foreach ($obs as $ob) {
218  if (ilObject::_lookupType(ilObject::_lookupObjId($ob)) != "cat") {
219  $value.= "nocat-";
220  }
221  }
222 
223  $obj->delete();
224 
225  $this->assertEquals("tree1-tree2-tree3-tree4-tree5-tree6-tree7-", $value);
226  }
static _hasUntrashedReference($a_obj_id)
checks wether an object has at least one reference that is not in trash
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.
if(!array_key_exists('StateId', $_REQUEST)) $id
static _isInTrash($a_ref_id)
checks wether object is in trash
static _lookupObjId($a_id)
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
+ 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: