ILIAS  release_7 Revision v7.30-3-g800a261c036
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 9 of file ilObjectTest.php.

Member Function Documentation

◆ setUp()

ilObjectTest::setUp ( )
protected

Definition at line 13 of file ilObjectTest.php.

13 : void
14 {
15 include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
16 ilUnitUtil::performInitialisation();
17 }

◆ testCreationDeletion()

ilObjectTest::testCreationDeletion ( )

@group IL_Init

Definition at line 22 of file ilObjectTest.php.

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

239 {
240 global $DIC;
241 $user = $DIC->user();
242
243 $ref_ids = ilObject::_getAllReferences(1);
244 $bool = ilObject::_setDeletedDate(1, $user->getId());
247
248 $this->assertEquals($date, null);
249 }
static _resetDeletedDate($a_ref_id)
only called in ilObjectGUI::insertSavedNodes
static _getAllReferences($a_id)
get all reference ids of object
static _setDeletedDate($a_ref_id, $a_deleted_by)
static _lookupDeletedDate($a_ref_id)
only called in ilObjectGUI::insertSavedNodes
global $DIC
Definition: goto.php:24

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

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

+ Here is the call graph for this function:

◆ testTreeTrash()

ilObjectTest::testTreeTrash ( )

@group IL_Init

Definition at line 172 of file ilObjectTest.php.

173 {
174 global $DIC;
175 $tree = $DIC->repositoryTree();
176 $user = $DIC->user();
177
178 $obj = new ilObject();
179 $obj->setType("xxx");
180 $obj->setTitle("TestObject");
181 $obj->setDescription("TestDescription");
182 $obj->setImportId("imp_44");
183 $obj->create();
184 $obj->createReference();
185 $id = $obj->getId();
186 $ref_id = $obj->getRefId();
187 $obj = new ilObject($ref_id);
188
189 $obj->putInTree(ROOT_FOLDER_ID);
190 $obj->setPermissions(ROOT_FOLDER_ID);
191 if ($tree->isInTree($ref_id)) {
192 $value .= "tree1-";
193 }
195 $value .= "tree2-";
196 }
197
198 // isSaved() uses internal cache!
199 $tree->useCache(false);
200 $tree->moveToTrash($ref_id, true, $user->getId());
201 if ($tree->isDeleted($ref_id)) {
202 $value .= "tree3-";
203 }
204 if ($tree->isSaved($ref_id)) {
205 $value .= "tree4-";
206 }
207 if (ilObject::_isInTrash($ref_id)) {
208 $value .= "tree5-";
209 }
211 $value .= "tree6-";
212 }
213
214 $saved_tree = new ilTree(-(int) $ref_id);
215 $node_data = $saved_tree->getNodeData($ref_id);
216 $saved_tree->deleteTree($node_data);
217
218 if (!ilObject::_isInTrash($ref_id)) {
219 $value .= "tree7-";
220 }
221
222 $obs = ilUtil::_getObjectsByOperations("cat", "read");
223 foreach ($obs as $ob) {
225 $value .= "nocat-";
226 }
227 }
228
229 $obj->delete();
230
231 $this->assertEquals("tree1-tree2-tree3-tree4-tree5-tree6-tree7-", $value);
232 }
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,...
const ROOT_FOLDER_ID
Definition: constants.php:30

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

+ Here is the call graph for this function:

Field Documentation

◆ $backupGlobals

ilObjectTest::$backupGlobals = false
protected

Definition at line 11 of file ilObjectTest.php.


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