ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 235 of file ilObjectTest.php.

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

236  {
237  include_once './Services/Object/classes/class.ilObject.php';
238 
239  $ref_ids = ilObject::_getAllReferences(1);
240  $bool = ilObject::_setDeletedDate(1);
241  $bool = ilObject::_resetDeletedDate(1);
242  $date = ilObject::_lookupDeletedDate(1);
243 
244  $this->assertEquals($date, null);
245  }
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 $DIC, $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 $DIC;
56  $ilUser = $DIC->user();
57 
58 
59  $obj = new ilObject();
60  $obj->setType(""); // otherwise type check will fail
61  $obj->setTitle("TestObject");
62  $obj->setDescription("TestDescription");
63  $obj->setImportId("imp_44");
64  $obj->create();
65  $obj->createReference();
66  $id = $obj->getId();
67  $ref_id = $obj->getRefId();
68  $obj = new ilObject($id, false);
69 
70  if ($obj->getType() == "") {
71  $value .= "sg1-";
72  }
73  if ($obj->getTitle() == "TestObject") {
74  $value .= "sg2-";
75  }
76  if ($obj->getDescription() == "TestDescription") {
77  $value .= "sg3-";
78  }
79  if ($obj->getImportId() == "imp_44") {
80  $value .= "sg4-";
81  }
82  if ($obj->getOwner() == $ilUser->getId()) {
83  $value .= "sg5-";
84  }
85 
86  $obj = new ilObject($ref_id);
87  if ($obj->getTitle() == "TestObject") {
88  $value .= "sg6-";
89  }
90 
91  if ($obj->getCreateDate() == ($lu = $obj->getLastUpdateDate())) {
92  $value .= "sg7-";
93  }
94  $obj->setTitle("TestObject2");
95  sleep(2); // we want a different date here...
96  $obj->update();
97 
98  $obj = new ilObject($ref_id);
99  if ($lu != ($lu2 = $obj->getLastUpdateDate())) {
100  $value .= "up1-";
101  }
102  if ($obj->getTitle() == "TestObject2") {
103  $value .= "up2-";
104  }
105 
106  if ($id == ilObject::_lookupObjIdByImportId("imp_44")) {
107  $value .= "lu1-";
108  }
109 
111  $value .= "lu2-";
112  }
113 
114  if (ilObject::_lookupTitle($id) == "TestObject2") {
115  $value .= "lu3-";
116  }
117  if (ilObject::_lookupDescription($id) == "TestDescription") {
118  $value .= "lu4-";
119  }
120  if (ilObject::_lookupLastUpdate($id) == $lu2) {
121  $value .= "lu5-";
122  }
123  if (ilObject::_lookupObjId($ref_id) == $id) {
124  $value .= "lu6-";
125  }
126  if (ilObject::_lookupType($id) == "") {
127  $value .= "lu7-";
128  }
129  if (ilObject::_lookupObjectId($ref_id) == $id) {
130  $value .= "lu8-";
131  }
133  if (is_array($ar) && count($ar) == 1 && $ar[$ref_id] == $ref_id) {
134  $value .= "lu9-";
135  }
136 
137  $ids = ilObject::_getIdsForTitle("TestObject2");
138  foreach ($ids as $i) {
139  if ($i == $id) {
140  $value .= "lu10-";
141  }
142  }
143 
144  $obs = ilObject::_getObjectsByType("usr");
145  foreach ($obs as $ob) {
146  if ($ob["obj_id"] == $ilUser->getId()) {
147  $value .= "lu11-";
148  }
149  }
150 
151  $d1 = ilObject::_lookupDeletedDate($ref_id);
152  ilObject::_setDeletedDate($ref_id);
153  $d2 = ilObject::_lookupDeletedDate($ref_id);
155  $d3 = ilObject::_lookupDeletedDate($ref_id);
156  if ($d1 != $d2 && $d1 == $d3 && $d3 == null) {
157  $value .= "dd1-";
158  }
159 
160  $obj->delete();
161 
162  $this->assertEquals("sg1-sg2-sg3-sg4-sg5-sg6-sg7-up1-up2-" .
163  "lu1-lu2-lu3-lu4-lu5-lu6-lu7-lu8-lu9-lu10-lu11-dd1-", $value);
164  }
static _resetDeletedDate($a_ref_id)
only called in ilObjectGUI::insertSavedNodes
static _lookupDeletedDate($a_ref_id)
only called in ilObjectGUI::insertSavedNodes
global $DIC
Definition: saml.php:7
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 169 of file ilObjectTest.php.

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

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