ILIAS  trunk Revision v11.0_alpha-1831-g8615d53dadb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\Repository\Deletion\DeletionTest Class Reference
+ Inheritance diagram for ILIAS\Repository\Deletion\DeletionTest:
+ Collaboration diagram for ILIAS\Repository\Deletion\DeletionTest:

Public Member Functions

 loadTreeData (int $data_id)
 
 resetDeleteRefIds ()
 
 createTreeInterfaceMock (int $tree_id)
 
 createPermissionInterfaceMock (bool $access_given)
 
 createObjectInterfaceMock (int $ref_id, array $failing_obj_ids=[])
 
 createEventInterfaceMock ()
 
 initDeletion (?TreeInterface $tree_mock=null, bool $trash_enabled=true, bool $access_given=true, array $failing_obj_ids=[])
 
 testTreeMockTest ()
 
 testDeletionInstantiation ()
 
 testDeletionDeleteWithTrash ()
 
 testDeletionDeleteWithTrashMultiple ()
 
 testDeletionDeleteWithoutTrash ()
 
 testDeletionDeleteRemoveFromSystem ()
 
 testDeletionRemoveFromSystemMultiple ()
 
 testDeletionRemoveFromSystemDeepSubtree ()
 
 testDeletionRemoveFromSystemTrashInTrash ()
 
 testDeletionRemoveFromSystemFailingObject ()
 
 testDeletionRemoveFromSystemTrashInTrashInTrash ()
 
 testDeletionNoDeletePermission ()
 
 testDeletionTrashDisabledTrashInTrashInTrash ()
 

Data Fields

array child
 

Protected Member Functions

 setUp ()
 
 addChilds ($id, &$childs, $data)
 
 log (string $message)
 
 tearDown ()
 

Protected Attributes

array $test_tree_data
 
array $tree_data = []
 
array $deleted_ref_ids = []
 

Detailed Description

Definition at line 23 of file DeletionTest.php.

Member Function Documentation

◆ addChilds()

ILIAS\Repository\Deletion\DeletionTest::addChilds (   $id,
$childs,
  $data 
)
protected

Definition at line 71 of file DeletionTest.php.

References $c, $data, and $id.

Referenced by ILIAS\Repository\Deletion\DeletionTest\createTreeInterfaceMock().

71  : void
72  {
73  foreach ($data as $k => $c) {
74  if ($c["parent"] == $id) {
75  $childs[$k] = $c;
76  $this->addChilds($c["child"], $childs, $data);
77  }
78  }
79  }
$c
Definition: deliver.php:25
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the caller graph for this function:

◆ createEventInterfaceMock()

ILIAS\Repository\Deletion\DeletionTest::createEventInterfaceMock ( )

Definition at line 265 of file DeletionTest.php.

References $ref_id, and ILIAS\Repository\Deletion\DeletionTest\log().

Referenced by ILIAS\Repository\Deletion\DeletionTest\initDeletion().

265  : EventInterface
266  {
267  // Create the mock object
268  $mock = $this->createMock(EventInterface::class);
269 
270  // Configure the beforeMoveToTrash method
271  $mock->method('beforeMoveToTrash')
272  ->willReturnCallback(function (int $ref_id, array $subnodes) {
273  $this->log('beforeMoveToTrash: ' . $ref_id);
274  // No return value as the method is void
275  });
276 
277  // Configure the afterMoveToTrash method
278  $mock->method('afterMoveToTrash')
279  ->willReturnCallback(function (int $ref_id, int $old_parent_ref_id) {
280  // No return value as the method is void
281  });
282 
283  // Configure the beforeSubtreeRemoval method
284  $mock->method('beforeSubtreeRemoval')
285  ->willReturnCallback(function (int $obj_id) {
286  $this->log('beforeSubtreeRemoval: ' . $obj_id);
287  // No return value as the method is void
288  });
289 
290  // Configure the beforeObjectRemoval method
291  $mock->method('beforeObjectRemoval')
292  ->willReturnCallback(function (int $obj_id, int $ref_id, string $type, string $title) {
293  $this->log('beforeObjectRemoval: ' . $obj_id);
294  // No return value as the method is void
295  });
296 
297  // Configure the afterObjectRemoval method
298  $mock->method('afterObjectRemoval')
299  ->willReturnCallback(function (int $obj_id, int $ref_id, string $type, int $old_parent_ref_id) {
300  // No return value as the method is void
301  });
302 
303  // Configure the afterTreeDeletion method
304  $mock->method('afterTreeDeletion')
305  ->willReturnCallback(function (int $tree_id, int $child) {
306  $this->log('afterTreeDeletion: ' . $tree_id . ", " . $child);
307  // No return value as the method is void
308  });
309 
310  return $mock;
311  }
$ref_id
Definition: ltiauth.php:65
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createObjectInterfaceMock()

ILIAS\Repository\Deletion\DeletionTest::createObjectInterfaceMock ( int  $ref_id,
array  $failing_obj_ids = [] 
)

Definition at line 214 of file DeletionTest.php.

References $ref_id.

Referenced by ILIAS\Repository\Deletion\DeletionTest\initDeletion().

214  : ObjectInterface
215  {
216  // Create the mock object
217  $mock = $this->createMock(ObjectInterface::class);
218 
219  // Configure the getInstanceByRefId method to return the mock itself or null
220  $mock->method('getInstanceByRefId')
221  ->willReturnCallback(function (int $ref_id) use ($mock, $failing_obj_ids) {
222  return $this->createObjectInterfaceMock($ref_id, $failing_obj_ids);
223  });
224 
225  // Configure the delete method
226  $mock->method('delete')
227  ->willReturnCallback(function () use ($ref_id, $failing_obj_ids) {
228  if (in_array($ref_id, $failing_obj_ids)) {
229  throw new \Exception("Failed to do something");
230  }
231  $this->deleted_ref_ids[] = $ref_id;
232  });
233 
234  // Configure the getId method
235  $mock->method('getId')
236  ->willReturnCallback(function () use ($ref_id) {
237  return $ref_id;
238  });
239 
240  // Configure the getType method
241  $mock->method('getType')
242  ->willReturn('tst');
243 
244  // Configure the getTitle method
245  $mock->method('getTitle')
246  ->willReturn('Sample Object Title');
247 
248  // Configure the getRefId method
249  $mock->method('getRefId')
250  ->willReturnCallback(function () use ($ref_id) {
251  return $ref_id;
252  });
253 
254  return $mock;
255  }
createObjectInterfaceMock(int $ref_id, array $failing_obj_ids=[])
$ref_id
Definition: ltiauth.php:65
+ Here is the caller graph for this function:

◆ createPermissionInterfaceMock()

ILIAS\Repository\Deletion\DeletionTest::createPermissionInterfaceMock ( bool  $access_given)

Definition at line 185 of file DeletionTest.php.

References $ref_id.

Referenced by ILIAS\Repository\Deletion\DeletionTest\initDeletion().

187  : PermissionInterface {
188  // Create the mock object
189  $mock = $this->createMock(PermissionInterface::class);
190 
191  // Configure the checkAccess method to return true or false based on operation and ref_id
192  $mock->method('checkAccess')
193  ->willReturnCallback(function (string $operation, int $ref_id) use ($access_given) {
194  return $access_given;
195  });
196 
197  // Configure the revokePermission method
198  $mock->method('revokePermission')
199  ->willReturnCallback(function (int $ref_id) {
200  });
201 
202  // Configure the getRefIdsWithoutDeletePermission method to return a filtered list of ids
203  $mock->method('getRefIdsWithoutDeletePermission')
204  ->willReturnCallback(function (array $ids) use ($access_given) {
205  if ($access_given) {
206  return [];
207  }
208  return $ids;
209  });
210 
211  return $mock;
212  }
$ref_id
Definition: ltiauth.php:65
+ Here is the caller graph for this function:

◆ createTreeInterfaceMock()

ILIAS\Repository\Deletion\DeletionTest::createTreeInterfaceMock ( int  $tree_id)

Definition at line 81 of file DeletionTest.php.

References $data, $id, $ref_id, and ILIAS\Repository\Deletion\DeletionTest\addChilds().

Referenced by ILIAS\Repository\Deletion\DeletionTest\testDeletionDeleteRemoveFromSystem(), ILIAS\Repository\Deletion\DeletionTest\testDeletionDeleteWithoutTrash(), ILIAS\Repository\Deletion\DeletionTest\testDeletionDeleteWithTrash(), ILIAS\Repository\Deletion\DeletionTest\testDeletionDeleteWithTrashMultiple(), ILIAS\Repository\Deletion\DeletionTest\testDeletionInstantiation(), ILIAS\Repository\Deletion\DeletionTest\testDeletionNoDeletePermission(), ILIAS\Repository\Deletion\DeletionTest\testDeletionRemoveFromSystemDeepSubtree(), ILIAS\Repository\Deletion\DeletionTest\testDeletionRemoveFromSystemFailingObject(), ILIAS\Repository\Deletion\DeletionTest\testDeletionRemoveFromSystemMultiple(), ILIAS\Repository\Deletion\DeletionTest\testDeletionRemoveFromSystemTrashInTrash(), ILIAS\Repository\Deletion\DeletionTest\testDeletionRemoveFromSystemTrashInTrashInTrash(), ILIAS\Repository\Deletion\DeletionTest\testDeletionTrashDisabledTrashInTrashInTrash(), and ILIAS\Repository\Deletion\DeletionTest\testTreeMockTest().

81  : TreeInterface
82  {
83  $mock = $this->createMock(TreeInterface::class);
84 
85  // isDeleted acts on all data entries of all trees
86  $mock->method('isDeleted')
87  ->willReturnCallback(function (int $child) {
88  foreach ($this->tree_data as $tree_id => $entries) {
89  if (isset($entries[$child])) {
90  return ($tree_id < 0);
91  }
92  }
93  return false;
94  });
95 
96  // getNodeData acts only on tree $tree_id
97  $mock->method('getNodeData')
98  ->willReturnCallback(function (int $child) use ($tree_id) {
99  return $this->tree_data[$tree_id][$child];
100  });
101 
102  $mock->method('useCache')
103  ->willReturnCallback(function (bool $a_use) {
104  });
105 
106  // getSubTree acts only on tree $tree_id
107  $mock->method('getSubTree')
108  ->willReturnCallback(function (array $node) use ($tree_id) {
109  $childs[$node["child"]] = $node;
110  $data = $this->tree_data[$tree_id];
111  $this->addChilds($node['child'], $childs, $data);
112  return $childs;
113  });
114 
115  // getDeletedTreeNodeIds acts on all data entries of all trees
116  $mock->method('getDeletedTreeNodeIds')
117  ->willReturnCallback(function (array $ids) use ($mock) {
118  $deleted_ids = [];
119  foreach ($ids as $id) {
120  if ($mock->isDeleted($id)) {
121  $deleted_ids[] = $id;
122  }
123  }
124  return $deleted_ids;
125  });
126 
127  // getTree acts on all data
128  $mock->method('getTree')
129  ->willReturnCallback(function (int $tree_id) {
130  return $this->createTreeInterfaceMock($tree_id);
131  });
132 
133  // getTrashTree acts on all data
134  $mock->method('getTrashTree')
135  ->willReturnCallback(function (int $child) use ($mock) {
136  foreach ($this->tree_data as $tree_id => $entries) {
137  if (isset($entries[$child]) && $tree_id < 0) {
138  return $mock->getTree($tree_id);
139  }
140  }
141  });
142 
143  // Configure the deleteTree method
144  $mock->method('moveToTrash')
145  ->willReturnCallback(function (int $child) use ($mock, $tree_id) {
146  $moved = false;
147  foreach ($mock->getSubTree($mock->getNodeData($child)) as $subnode) {
148  if (isset($this->tree_data[$tree_id][$subnode["child"]])) {
149  unset($this->tree_data[$tree_id][$subnode["child"]]);
150  $subnode["tree"] = -$child;
151  $this->tree_data[-$child][$subnode["child"]] = $subnode;
152  $moved = true;
153  }
154  }
155  return $moved;
156  });
157 
158  // Configure the deleteTree method
159  $mock->method('deleteTree')
160  ->willReturnCallback(function (array $node_data) use ($mock, $tree_id) {
161  foreach ($mock->getSubTree($node_data) as $subnode) {
162  unset($this->tree_data[$tree_id][$subnode["child"]]);
163  }
164  });
165 
166  // Configure the getTrashedSubtrees method
167  $mock->method('getTrashedSubtrees')
168  ->willReturnCallback(function (int $ref_id) {
169  $tree_ids = [];
170  foreach ($this->tree_data as $tree_id => $entries) {
171  foreach ($entries as $entry) {
172  if ($entry["parent"] == $ref_id) {
173  if ($tree_id < 0 && $tree_id === -1 * $entry["child"]) {
174  $tree_ids[] = $tree_id;
175  }
176  }
177  }
178  }
179  return $tree_ids;
180  });
181 
182  return $mock;
183  }
$ref_id
Definition: ltiauth.php:65
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initDeletion()

ILIAS\Repository\Deletion\DeletionTest::initDeletion ( ?TreeInterface  $tree_mock = null,
bool  $trash_enabled = true,
bool  $access_given = true,
array  $failing_obj_ids = [] 
)

Definition at line 313 of file DeletionTest.php.

References ILIAS\Repository\Deletion\DeletionTest\createEventInterfaceMock(), ILIAS\Repository\Deletion\DeletionTest\createObjectInterfaceMock(), and ILIAS\Repository\Deletion\DeletionTest\createPermissionInterfaceMock().

Referenced by ILIAS\Repository\Deletion\DeletionTest\testDeletionDeleteRemoveFromSystem(), ILIAS\Repository\Deletion\DeletionTest\testDeletionDeleteWithoutTrash(), ILIAS\Repository\Deletion\DeletionTest\testDeletionDeleteWithTrash(), ILIAS\Repository\Deletion\DeletionTest\testDeletionDeleteWithTrashMultiple(), ILIAS\Repository\Deletion\DeletionTest\testDeletionInstantiation(), ILIAS\Repository\Deletion\DeletionTest\testDeletionNoDeletePermission(), ILIAS\Repository\Deletion\DeletionTest\testDeletionRemoveFromSystemDeepSubtree(), ILIAS\Repository\Deletion\DeletionTest\testDeletionRemoveFromSystemFailingObject(), ILIAS\Repository\Deletion\DeletionTest\testDeletionRemoveFromSystemMultiple(), ILIAS\Repository\Deletion\DeletionTest\testDeletionRemoveFromSystemTrashInTrash(), ILIAS\Repository\Deletion\DeletionTest\testDeletionRemoveFromSystemTrashInTrashInTrash(), and ILIAS\Repository\Deletion\DeletionTest\testDeletionTrashDisabledTrashInTrashInTrash().

318  : Deletion {
319  return new Deletion(
320  $tree_mock,
321  $this->createPermissionInterfaceMock($access_given),
322  $this->createEventInterfaceMock(),
323  $this->createObjectInterfaceMock(0, $failing_obj_ids),
324  $trash_enabled
325  );
326  }
createObjectInterfaceMock(int $ref_id, array $failing_obj_ids=[])
createPermissionInterfaceMock(bool $access_given)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadTreeData()

◆ log()

◆ resetDeleteRefIds()

◆ setUp()

ILIAS\Repository\Deletion\DeletionTest::setUp ( )
protected

Definition at line 56 of file DeletionTest.php.

56  : void
57  {
58  parent::setUp();
59  }

◆ tearDown()

ILIAS\Repository\Deletion\DeletionTest::tearDown ( )
protected

Definition at line 327 of file DeletionTest.php.

327  : void
328  {
329  }

◆ testDeletionDeleteRemoveFromSystem()

ILIAS\Repository\Deletion\DeletionTest::testDeletionDeleteRemoveFromSystem ( )
  • trash enabled
  • access given
  • delete 2
  • removeFromSystem 2
  • check if 2 is NOT in trash (isDeleted)
  • check if 1 does not have trashed subtrees
  • check if 2,4 are finally deleted

Definition at line 457 of file DeletionTest.php.

References ILIAS\Repository\Deletion\DeletionTest\createTreeInterfaceMock(), ILIAS\Repository\Deletion\DeletionTest\initDeletion(), ILIAS\Repository\Deletion\DeletionTest\loadTreeData(), and ILIAS\Repository\Deletion\DeletionTest\resetDeleteRefIds().

457  : void
458  {
459  $this->loadTreeData(1);
460  $this->resetDeleteRefIds();
461  $tree_mock = $this->createTreeInterfaceMock(1);
462  $deletion = $this->initDeletion(
463  $tree_mock,
464  true,
465  true
466  );
467 
468  // delete tree 2
469  $deletion->deleteObjectsByRefIds([2]);
470 
471  $deletion->removeObjectsFromSystemByRefIds([2]);
472 
473  // 2 is not in trash
474  $this->assertEquals(false, $tree_mock->isDeleted(2));
475 
476  // no left trashed subtrees
477  $this->assertEquals([], $tree_mock->getTrashedSubtrees(1));
478 
479  // 2,4 have been deleted
480  $this->assertEquals([2,4], $this->deleted_ref_ids);
481  }
initDeletion(?TreeInterface $tree_mock=null, bool $trash_enabled=true, bool $access_given=true, array $failing_obj_ids=[])
+ Here is the call graph for this function:

◆ testDeletionDeleteWithoutTrash()

ILIAS\Repository\Deletion\DeletionTest::testDeletionDeleteWithoutTrash ( )
  • trash disabled
  • access given
  • delete 2
  • check if 2 is NOT in trash (isDeleted)
  • check if 1 does not have trashed subtrees
  • check if 2,4 are finally deleted

Definition at line 424 of file DeletionTest.php.

References ILIAS\Repository\Deletion\DeletionTest\createTreeInterfaceMock(), ILIAS\Repository\Deletion\DeletionTest\initDeletion(), ILIAS\Repository\Deletion\DeletionTest\loadTreeData(), and ILIAS\Repository\Deletion\DeletionTest\resetDeleteRefIds().

424  : void
425  {
426  $this->loadTreeData(1);
427  $this->resetDeleteRefIds();
428  $tree_mock = $this->createTreeInterfaceMock(1);
429  $deletion = $this->initDeletion(
430  $tree_mock,
431  false,
432  true
433  );
434 
435  // delete tree 2
436  $deletion->deleteObjectsByRefIds([2]);
437 
438  // tree is not in trash
439  $this->assertEquals(false, $tree_mock->isDeleted(2));
440 
441  // no trashed subtrees
442  $this->assertEquals([], $tree_mock->getTrashedSubtrees(1));
443 
444  // 2 has been deleted
445  $this->assertEquals([2,4], $this->deleted_ref_ids);
446  }
initDeletion(?TreeInterface $tree_mock=null, bool $trash_enabled=true, bool $access_given=true, array $failing_obj_ids=[])
+ Here is the call graph for this function:

◆ testDeletionDeleteWithTrash()

ILIAS\Repository\Deletion\DeletionTest::testDeletionDeleteWithTrash ( )
  • trash enabled
  • access given
  • delete 2
  • check if 2 is in trash (isDeleted)
  • check if -2 is trashed subtree of 1
  • check if nothing has been finally deleted

Definition at line 365 of file DeletionTest.php.

References ILIAS\Repository\Deletion\DeletionTest\createTreeInterfaceMock(), ILIAS\Repository\Deletion\DeletionTest\initDeletion(), ILIAS\Repository\Deletion\DeletionTest\loadTreeData(), and ILIAS\Repository\Deletion\DeletionTest\resetDeleteRefIds().

365  : void
366  {
367  $this->loadTreeData(1);
368  $this->resetDeleteRefIds();
369  $tree_mock = $this->createTreeInterfaceMock(1);
370  $deletion = $this->initDeletion(
371  $tree_mock,
372  true,
373  true
374  );
375 
376  $deletion->deleteObjectsByRefIds([2]);
377  $this->assertEquals(true, $tree_mock->isDeleted(2));
378 
379  $this->assertEquals([-2], $tree_mock->getTrashedSubtrees(1));
380 
381  // nothing has been finally deleted
382  $this->assertEquals([], $this->deleted_ref_ids);
383  }
initDeletion(?TreeInterface $tree_mock=null, bool $trash_enabled=true, bool $access_given=true, array $failing_obj_ids=[])
+ Here is the call graph for this function:

◆ testDeletionDeleteWithTrashMultiple()

ILIAS\Repository\Deletion\DeletionTest::testDeletionDeleteWithTrashMultiple ( )
  • trash enabled
  • access given
  • delete 2
  • delete 3
  • check if 2,3 are in trash (isDeleted)
  • check if -2,-3 are trashed subtrees of 1
  • check if nothing has been finally deleted

Definition at line 394 of file DeletionTest.php.

References ILIAS\Repository\Deletion\DeletionTest\createTreeInterfaceMock(), ILIAS\Repository\Deletion\DeletionTest\initDeletion(), ILIAS\Repository\Deletion\DeletionTest\loadTreeData(), and ILIAS\Repository\Deletion\DeletionTest\resetDeleteRefIds().

394  : void
395  {
396  $this->loadTreeData(1);
397  $this->resetDeleteRefIds();
398  $tree_mock = $this->createTreeInterfaceMock(1);
399  $deletion = $this->initDeletion(
400  $tree_mock,
401  true,
402  true
403  );
404 
405  $deletion->deleteObjectsByRefIds([2]);
406  $deletion->deleteObjectsByRefIds([3]);
407  $this->assertEquals(true, $tree_mock->isDeleted(2));
408  $this->assertEquals(true, $tree_mock->isDeleted(3));
409 
410  $this->assertEquals([-2, -3], $tree_mock->getTrashedSubtrees(1));
411 
412  // nothing has been finally deleted
413  $this->assertEquals([], $this->deleted_ref_ids);
414  }
initDeletion(?TreeInterface $tree_mock=null, bool $trash_enabled=true, bool $access_given=true, array $failing_obj_ids=[])
+ Here is the call graph for this function:

◆ testDeletionInstantiation()

ILIAS\Repository\Deletion\DeletionTest::testDeletionInstantiation ( )

Definition at line 343 of file DeletionTest.php.

References ILIAS\Repository\Deletion\DeletionTest\createTreeInterfaceMock(), ILIAS\Repository\Deletion\DeletionTest\initDeletion(), ILIAS\Repository\Deletion\DeletionTest\loadTreeData(), and ILIAS\Repository\Deletion\DeletionTest\resetDeleteRefIds().

343  : void
344  {
345  $this->loadTreeData(1);
346  $this->resetDeleteRefIds();
347  $tree_mock = $this->createTreeInterfaceMock(1);
348  $deletion = $this->initDeletion(
349  $tree_mock,
350  true,
351  true
352  );
353 
354  static::assertInstanceOf(Deletion::class, $deletion);
355  }
initDeletion(?TreeInterface $tree_mock=null, bool $trash_enabled=true, bool $access_given=true, array $failing_obj_ids=[])
+ Here is the call graph for this function:

◆ testDeletionNoDeletePermission()

ILIAS\Repository\Deletion\DeletionTest::testDeletionNoDeletePermission ( )

Definition at line 723 of file DeletionTest.php.

References ILIAS\Repository\Deletion\DeletionTest\createTreeInterfaceMock(), ILIAS\Repository\Deletion\DeletionTest\initDeletion(), ILIAS\Repository\Deletion\DeletionTest\loadTreeData(), ILIAS\Repository\Deletion\DeletionTest\log(), and ILIAS\Repository\Deletion\DeletionTest\resetDeleteRefIds().

723  : void
724  {
725  $this->log(PHP_EOL . "---testDeletionNoDeletePermission");
726  $this->loadTreeData(1);
727  $this->resetDeleteRefIds();
728  $tree_mock = $this->createTreeInterfaceMock(1);
729  $deletion = $this->initDeletion(
730  $tree_mock,
731  true,
732  false,
733  [8]
734  );
735 
736  $this->log("---call: deleteObjectsByRefIds 9");
737  $this->expectException(MissingPermissionException::class);
738  $deletion->deleteObjectsByRefIds([9]);
739 
740  // 9 not in trash
741  $this->assertEquals(false, $tree_mock->isDeleted(9));
742 
743  // no trashed subtrees
744  $this->assertEquals([], $tree_mock->getTrashedSubtrees(1));
745  $this->assertEquals([], $tree_mock->getTrashedSubtrees(2));
746 
747  // nothing deleted
748  $this->assertEqualsCanonicalizing([], $this->deleted_ref_ids);
749  $this->log("---END---testDeletionNoDeletePermission");
750  }
initDeletion(?TreeInterface $tree_mock=null, bool $trash_enabled=true, bool $access_given=true, array $failing_obj_ids=[])
+ Here is the call graph for this function:

◆ testDeletionRemoveFromSystemDeepSubtree()

ILIAS\Repository\Deletion\DeletionTest::testDeletionRemoveFromSystemDeepSubtree ( )
  • trash enabled
  • access given
  • delete 8
  • delete 3
  • removeFromSystem 3
  • check if 3,5,6,7,8,9 are finally deleted

Definition at line 537 of file DeletionTest.php.

References ILIAS\Repository\Deletion\DeletionTest\createTreeInterfaceMock(), ILIAS\Repository\Deletion\DeletionTest\initDeletion(), ILIAS\Repository\Deletion\DeletionTest\loadTreeData(), ILIAS\Repository\Deletion\DeletionTest\log(), and ILIAS\Repository\Deletion\DeletionTest\resetDeleteRefIds().

537  : void
538  {
539  $this->log(PHP_EOL . "---testDeletionDeleteRemoveFromSystemMultiple");
540  $this->loadTreeData(1);
541  $this->resetDeleteRefIds();
542  $tree_mock = $this->createTreeInterfaceMock(1);
543  $deletion = $this->initDeletion(
544  $tree_mock,
545  true,
546  true
547  );
548 
549  // delete tree 2
550  $this->log("---call: deleteObjectsByRefIds 8");
551  $deletion->deleteObjectsByRefIds([8]);
552  $this->log("---call: deleteObjectsByRefIds 3");
553  $deletion->deleteObjectsByRefIds([3]);
554 
555  $this->log("---call: removeObjectsFromSystemByRefIds 3");
556  $deletion->removeObjectsFromSystemByRefIds([3]);
557 
558  // 3,5,6,7,8 are not in trash
559  $this->assertEquals(false, $tree_mock->isDeleted(3));
560  $this->assertEquals(false, $tree_mock->isDeleted(5));
561  $this->assertEquals(false, $tree_mock->isDeleted(6));
562  $this->assertEquals(false, $tree_mock->isDeleted(7));
563  $this->assertEquals(false, $tree_mock->isDeleted(8));
564  $this->assertEquals(false, $tree_mock->isDeleted(9));
565 
566  // no left trashed subtrees
567  $this->assertEquals([], $tree_mock->getTrashedSubtrees(1));
568  $this->assertEquals([], $tree_mock->getTrashedSubtrees(2));
569 
570  // 3,5,6,7,8,9 have been deleted
571  $this->assertEqualsCanonicalizing([3,5,6,7,8,9], $this->deleted_ref_ids);
572  $this->log("---END---testDeletionDeleteRemoveFromSystemMultiple");
573  }
initDeletion(?TreeInterface $tree_mock=null, bool $trash_enabled=true, bool $access_given=true, array $failing_obj_ids=[])
+ Here is the call graph for this function:

◆ testDeletionRemoveFromSystemFailingObject()

ILIAS\Repository\Deletion\DeletionTest::testDeletionRemoveFromSystemFailingObject ( )
  • trash enabled
  • access given
  • delete 8
  • delete 3
  • removeFromSystem 3 (8 fails)
  • check if 3,5,6,7,9 are finally deleted

Definition at line 631 of file DeletionTest.php.

References ILIAS\Repository\Deletion\DeletionTest\createTreeInterfaceMock(), ILIAS\Repository\Deletion\DeletionTest\initDeletion(), ILIAS\Repository\Deletion\DeletionTest\loadTreeData(), ILIAS\Repository\Deletion\DeletionTest\log(), and ILIAS\Repository\Deletion\DeletionTest\resetDeleteRefIds().

631  : void
632  {
633  $this->log(PHP_EOL . "---testDeletionRemoveFromSystemFailingObject");
634  $this->loadTreeData(1);
635  $this->resetDeleteRefIds();
636  $tree_mock = $this->createTreeInterfaceMock(1);
637  $deletion = $this->initDeletion(
638  $tree_mock,
639  true,
640  true,
641  [8]
642  );
643 
644  $this->log("---call: deleteObjectsByRefIds 9");
645  $deletion->deleteObjectsByRefIds([9]);
646  $this->log("---call: deleteObjectsByRefIds 8");
647  $deletion->deleteObjectsByRefIds([8]);
648  $this->log("---call: deleteObjectsByRefIds 3");
649  $deletion->deleteObjectsByRefIds([3]);
650 
651  $this->log("---call: removeObjectsFromSystemByRefIds 3");
652  $deletion->removeObjectsFromSystemByRefIds([3]);
653 
654  // 3,5,6,7,8 are not in trash
655  $this->assertEquals(false, $tree_mock->isDeleted(3));
656  $this->assertEquals(false, $tree_mock->isDeleted(5));
657  $this->assertEquals(false, $tree_mock->isDeleted(6));
658  $this->assertEquals(false, $tree_mock->isDeleted(7));
659  $this->assertEquals(false, $tree_mock->isDeleted(8));
660  $this->assertEquals(false, $tree_mock->isDeleted(9));
661 
662  // no left trashed subtrees
663  $this->assertEquals([], $tree_mock->getTrashedSubtrees(1));
664  $this->assertEquals([], $tree_mock->getTrashedSubtrees(2));
665 
666  // 3,5,6,7,8,9 have been deleted
667  $this->assertEqualsCanonicalizing([3,5,6,7,9], $this->deleted_ref_ids);
668  $this->log("---END---testDeletionRemoveFromSystemFailingObject");
669  }
initDeletion(?TreeInterface $tree_mock=null, bool $trash_enabled=true, bool $access_given=true, array $failing_obj_ids=[])
+ Here is the call graph for this function:

◆ testDeletionRemoveFromSystemMultiple()

ILIAS\Repository\Deletion\DeletionTest::testDeletionRemoveFromSystemMultiple ( )
  • trash enabled
  • access given
  • delete 6
  • delete 3
  • removeFromSystem 3
  • check if 3,5,6,7,8,9 are finally deleted

Definition at line 491 of file DeletionTest.php.

References ILIAS\Repository\Deletion\DeletionTest\createTreeInterfaceMock(), ILIAS\Repository\Deletion\DeletionTest\initDeletion(), ILIAS\Repository\Deletion\DeletionTest\loadTreeData(), ILIAS\Repository\Deletion\DeletionTest\log(), and ILIAS\Repository\Deletion\DeletionTest\resetDeleteRefIds().

491  : void
492  {
493  $this->log(PHP_EOL . "---testDeletionDeleteRemoveFromSystemMultiple");
494  $this->loadTreeData(1);
495  $this->resetDeleteRefIds();
496  $tree_mock = $this->createTreeInterfaceMock(1);
497  $deletion = $this->initDeletion(
498  $tree_mock,
499  true,
500  true
501  );
502 
503  // delete tree 2
504  $this->log("---call: deleteObjectsByRefIds 6");
505  $deletion->deleteObjectsByRefIds([6]);
506  $this->log("---call: deleteObjectsByRefIds 3");
507  $deletion->deleteObjectsByRefIds([3]);
508 
509  $this->log("---call: removeObjectsFromSystemByRefIds 3");
510  $deletion->removeObjectsFromSystemByRefIds([3]);
511 
512  // 3,5,6,7,8 are not in trash
513  $this->assertEquals(false, $tree_mock->isDeleted(3));
514  $this->assertEquals(false, $tree_mock->isDeleted(5));
515  $this->assertEquals(false, $tree_mock->isDeleted(6));
516  $this->assertEquals(false, $tree_mock->isDeleted(7));
517  $this->assertEquals(false, $tree_mock->isDeleted(8));
518  $this->assertEquals(false, $tree_mock->isDeleted(9));
519 
520  // no left trashed subtrees
521  $this->assertEquals([], $tree_mock->getTrashedSubtrees(1));
522  $this->assertEquals([], $tree_mock->getTrashedSubtrees(2));
523 
524  // 3,5,6,7,8 have been deleted
525  $this->assertEqualsCanonicalizing([3,5,6,7,8,9], $this->deleted_ref_ids);
526  $this->log("---END---testDeletionDeleteRemoveFromSystemMultiple");
527  }
initDeletion(?TreeInterface $tree_mock=null, bool $trash_enabled=true, bool $access_given=true, array $failing_obj_ids=[])
+ Here is the call graph for this function:

◆ testDeletionRemoveFromSystemTrashInTrash()

ILIAS\Repository\Deletion\DeletionTest::testDeletionRemoveFromSystemTrashInTrash ( )
  • trash enabled
  • access given
  • delete 9
  • delete 8
  • delete 3
  • removeFromSystem 3
  • check if 3,5,6,7,8,9 are finally deleted

Definition at line 584 of file DeletionTest.php.

References ILIAS\Repository\Deletion\DeletionTest\createTreeInterfaceMock(), ILIAS\Repository\Deletion\DeletionTest\initDeletion(), ILIAS\Repository\Deletion\DeletionTest\loadTreeData(), ILIAS\Repository\Deletion\DeletionTest\log(), and ILIAS\Repository\Deletion\DeletionTest\resetDeleteRefIds().

584  : void
585  {
586  $this->log(PHP_EOL . "---testDeletionRemoveFromSystemTrashInTrash");
587  $this->loadTreeData(1);
588  $this->resetDeleteRefIds();
589  $tree_mock = $this->createTreeInterfaceMock(1);
590  $deletion = $this->initDeletion(
591  $tree_mock,
592  true,
593  true
594  );
595 
596  $this->log("---call: deleteObjectsByRefIds 9");
597  $deletion->deleteObjectsByRefIds([9]);
598  $this->log("---call: deleteObjectsByRefIds 8");
599  $deletion->deleteObjectsByRefIds([8]);
600  $this->log("---call: deleteObjectsByRefIds 3");
601  $deletion->deleteObjectsByRefIds([3]);
602 
603  $this->log("---call: removeObjectsFromSystemByRefIds 3");
604  $deletion->removeObjectsFromSystemByRefIds([3]);
605 
606  // 3,5,6,7,8 are not in trash
607  $this->assertEquals(false, $tree_mock->isDeleted(3));
608  $this->assertEquals(false, $tree_mock->isDeleted(5));
609  $this->assertEquals(false, $tree_mock->isDeleted(6));
610  $this->assertEquals(false, $tree_mock->isDeleted(7));
611  $this->assertEquals(false, $tree_mock->isDeleted(8));
612  $this->assertEquals(false, $tree_mock->isDeleted(9));
613 
614  // no left trashed subtrees
615  $this->assertEquals([], $tree_mock->getTrashedSubtrees(1));
616  $this->assertEquals([], $tree_mock->getTrashedSubtrees(2));
617 
618  // 3,5,6,7,8,9 have been deleted
619  $this->assertEqualsCanonicalizing([3,5,6,7,8,9], $this->deleted_ref_ids);
620  $this->log("---END---testDeletionRemoveFromSystemTrashInTrash");
621  }
initDeletion(?TreeInterface $tree_mock=null, bool $trash_enabled=true, bool $access_given=true, array $failing_obj_ids=[])
+ Here is the call graph for this function:

◆ testDeletionRemoveFromSystemTrashInTrashInTrash()

ILIAS\Repository\Deletion\DeletionTest::testDeletionRemoveFromSystemTrashInTrashInTrash ( )
  • trash enabled
  • access given
  • delete 9
  • delete 8
  • delete 6
  • delete 3
  • removeFromSystem 3
  • check if 3,5,6,7,9 are finally deleted

Definition at line 681 of file DeletionTest.php.

References ILIAS\Repository\Deletion\DeletionTest\createTreeInterfaceMock(), ILIAS\Repository\Deletion\DeletionTest\initDeletion(), ILIAS\Repository\Deletion\DeletionTest\loadTreeData(), ILIAS\Repository\Deletion\DeletionTest\log(), and ILIAS\Repository\Deletion\DeletionTest\resetDeleteRefIds().

681  : void
682  {
683  $this->log(PHP_EOL . "---testDeletionRemoveFromSystemTrashInTrashInTrash");
684  $this->loadTreeData(1);
685  $this->resetDeleteRefIds();
686  $tree_mock = $this->createTreeInterfaceMock(1);
687  $deletion = $this->initDeletion(
688  $tree_mock,
689  true,
690  true,
691  [8]
692  );
693 
694  $this->log("---call: deleteObjectsByRefIds 9");
695  $deletion->deleteObjectsByRefIds([9]);
696  $this->log("---call: deleteObjectsByRefIds 8");
697  $deletion->deleteObjectsByRefIds([8]);
698  $this->log("---call: deleteObjectsByRefIds 6");
699  $deletion->deleteObjectsByRefIds([6]);
700  $this->log("---call: deleteObjectsByRefIds 3");
701  $deletion->deleteObjectsByRefIds([3]);
702 
703  $this->log("---call: removeObjectsFromSystemByRefIds 3");
704  $deletion->removeObjectsFromSystemByRefIds([3]);
705 
706  // 3,5,6,7,8 are not in trash
707  $this->assertEquals(false, $tree_mock->isDeleted(3));
708  $this->assertEquals(false, $tree_mock->isDeleted(5));
709  $this->assertEquals(false, $tree_mock->isDeleted(6));
710  $this->assertEquals(false, $tree_mock->isDeleted(7));
711  $this->assertEquals(false, $tree_mock->isDeleted(8));
712  $this->assertEquals(false, $tree_mock->isDeleted(9));
713 
714  // no left trashed subtrees
715  $this->assertEquals([], $tree_mock->getTrashedSubtrees(1));
716  $this->assertEquals([], $tree_mock->getTrashedSubtrees(2));
717 
718  // 3,5,6,7,8,9 have been deleted
719  $this->assertEqualsCanonicalizing([3,5,6,7,9], $this->deleted_ref_ids);
720  $this->log("---END---testDeletionRemoveFromSystemTrashInTrashInTrash");
721  }
initDeletion(?TreeInterface $tree_mock=null, bool $trash_enabled=true, bool $access_given=true, array $failing_obj_ids=[])
+ Here is the call graph for this function:

◆ testDeletionTrashDisabledTrashInTrashInTrash()

ILIAS\Repository\Deletion\DeletionTest::testDeletionTrashDisabledTrashInTrashInTrash ( )
  • trash disabled
  • access given
  • delete 9
  • delete 8
  • delete 6
  • delete 3
  • check if 3,5,6,7,9 are finally deleted

Definition at line 761 of file DeletionTest.php.

References ILIAS\Repository\Deletion\DeletionTest\createTreeInterfaceMock(), ILIAS\Repository\Deletion\DeletionTest\initDeletion(), ILIAS\Repository\Deletion\DeletionTest\loadTreeData(), ILIAS\Repository\Deletion\DeletionTest\log(), and ILIAS\Repository\Deletion\DeletionTest\resetDeleteRefIds().

761  : void
762  {
763  $this->log(PHP_EOL . "---testDeletionTrashDisabledTrashInTrashInTrash");
764  $this->loadTreeData(1);
765  $this->resetDeleteRefIds();
766  $tree_mock = $this->createTreeInterfaceMock(1);
767  $deletion = $this->initDeletion(
768  $tree_mock,
769  false,
770  true,
771  []
772  );
773 
774  $this->log("---call: deleteObjectsByRefIds 9");
775  $deletion->deleteObjectsByRefIds([9]);
776  $this->log("---call: deleteObjectsByRefIds 8");
777  $deletion->deleteObjectsByRefIds([8]);
778  $this->log("---call: deleteObjectsByRefIds 6");
779  $deletion->deleteObjectsByRefIds([6]);
780  $this->log("---call: deleteObjectsByRefIds 3");
781  $deletion->deleteObjectsByRefIds([3]);
782 
783  // 3,5,6,7,8,9 are not in trash
784  $this->assertEquals(false, $tree_mock->isDeleted(3));
785  $this->assertEquals(false, $tree_mock->isDeleted(5));
786  $this->assertEquals(false, $tree_mock->isDeleted(6));
787  $this->assertEquals(false, $tree_mock->isDeleted(7));
788  $this->assertEquals(false, $tree_mock->isDeleted(8));
789  $this->assertEquals(false, $tree_mock->isDeleted(9));
790 
791  // no left trashed subtrees
792  $this->assertEquals([], $tree_mock->getTrashedSubtrees(1));
793  $this->assertEquals([], $tree_mock->getTrashedSubtrees(2));
794 
795  // 3,5,6,7,8,9 have been deleted
796  $this->assertEqualsCanonicalizing([3,5,6,7,8,9], $this->deleted_ref_ids);
797  $this->log("---END---testDeletionTrashDisabledTrashInTrashInTrash");
798  }
initDeletion(?TreeInterface $tree_mock=null, bool $trash_enabled=true, bool $access_given=true, array $failing_obj_ids=[])
+ Here is the call graph for this function:

◆ testTreeMockTest()

ILIAS\Repository\Deletion\DeletionTest::testTreeMockTest ( )

Definition at line 331 of file DeletionTest.php.

References ILIAS\Repository\Deletion\DeletionTest\createTreeInterfaceMock(), and ILIAS\Repository\Deletion\DeletionTest\loadTreeData().

331  : void
332  {
333  $this->loadTreeData(1);
334  $tree_mock = $this->createTreeInterfaceMock(1);
335 
336  $node1 = $tree_mock->getNodeData(1);
337  $this->assertEquals(0, $node1["parent"]);
338 
339  $tree_mock->moveToTrash(2);
340  $this->assertEquals(true, $tree_mock->isDeleted(2));
341  }
+ Here is the call graph for this function:

Field Documentation

◆ $deleted_ref_ids

array ILIAS\Repository\Deletion\DeletionTest::$deleted_ref_ids = []
protected

Definition at line 54 of file DeletionTest.php.

◆ $test_tree_data

array ILIAS\Repository\Deletion\DeletionTest::$test_tree_data
protected
Initial value:
= [
1 => [
1 => [
1 => ["tree" => 1

Definition at line 25 of file DeletionTest.php.

◆ $tree_data

array ILIAS\Repository\Deletion\DeletionTest::$tree_data = []
protected

Definition at line 52 of file DeletionTest.php.

◆ child

array ILIAS\Repository\Deletion\DeletionTest::child
Initial value:
=> 1, "ref_id" => 1, "obj_id" => 1, "parent" => 0],
2 => ["tree" => 1, "child" => 2, "ref_id" => 2, "obj_id" => 2, "parent" => 1],
3 => ["tree" => 1, "child" => 3, "ref_id" => 3, "obj_id" => 3, "parent" => 1],
4 => ["tree" => 1, "child" => 4, "ref_id" => 4, "obj_id" => 4, "parent" => 2],
5 => ["tree" => 1, "child" => 5, "ref_id" => 5, "obj_id" => 5, "parent" => 3],
6 => ["tree" => 1, "child" => 6, "ref_id" => 6, "obj_id" => 6, "parent" => 3],
7 => ["tree" => 1, "child" => 7, "ref_id" => 7, "obj_id" => 7, "parent" => 6],
8 => ["tree" => 1, "child" => 8, "ref_id" => 8, "obj_id" => 8, "parent" => 6],
9 => ["tree" => 1, "child" => 9, "ref_id" => 9, "obj_id" => 9, "parent" => 8],
]
]
]

Definition at line 39 of file DeletionTest.php.


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