ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
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 7 of file DeletionTest.php.

Member Function Documentation

◆ addChilds()

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

Definition at line 55 of file DeletionTest.php.

References $c, $data, and $id.

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

55  : void
56  {
57  foreach ($data as $k => $c) {
58  if ($c["parent"] == $id) {
59  $childs[$k] = $c;
60  $this->addChilds($c["child"], $childs, $data);
61  }
62  }
63  }
$c
Definition: deliver.php:9
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:24
+ Here is the caller graph for this function:

◆ createEventInterfaceMock()

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

Definition at line 249 of file DeletionTest.php.

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

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

249  : EventInterface
250  {
251  // Create the mock object
252  $mock = $this->createMock(EventInterface::class);
253 
254  // Configure the beforeMoveToTrash method
255  $mock->method('beforeMoveToTrash')
256  ->willReturnCallback(function (int $ref_id, array $subnodes) {
257  $this->log('beforeMoveToTrash: ' . $ref_id);
258  // No return value as the method is void
259  });
260 
261  // Configure the afterMoveToTrash method
262  $mock->method('afterMoveToTrash')
263  ->willReturnCallback(function (int $ref_id, int $old_parent_ref_id) {
264  // No return value as the method is void
265  });
266 
267  // Configure the beforeSubtreeRemoval method
268  $mock->method('beforeSubtreeRemoval')
269  ->willReturnCallback(function (int $obj_id) {
270  $this->log('beforeSubtreeRemoval: ' . $obj_id);
271  // No return value as the method is void
272  });
273 
274  // Configure the beforeObjectRemoval method
275  $mock->method('beforeObjectRemoval')
276  ->willReturnCallback(function (int $obj_id, int $ref_id, string $type, string $title) {
277  $this->log('beforeObjectRemoval: ' . $obj_id);
278  // No return value as the method is void
279  });
280 
281  // Configure the afterObjectRemoval method
282  $mock->method('afterObjectRemoval')
283  ->willReturnCallback(function (int $obj_id, int $ref_id, string $type, int $old_parent_ref_id) {
284  // No return value as the method is void
285  });
286 
287  // Configure the afterTreeDeletion method
288  $mock->method('afterTreeDeletion')
289  ->willReturnCallback(function (int $tree_id, int $child) {
290  $this->log('afterTreeDeletion: ' . $tree_id . ", " . $child);
291  // No return value as the method is void
292  });
293 
294  return $mock;
295  }
$ref_id
Definition: ltiauth.php:66
+ 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 198 of file DeletionTest.php.

References $ref_id.

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

198  : ObjectInterface
199  {
200  // Create the mock object
201  $mock = $this->createMock(ObjectInterface::class);
202 
203  // Configure the getInstanceByRefId method to return the mock itself or null
204  $mock->method('getInstanceByRefId')
205  ->willReturnCallback(function (int $ref_id) use ($mock, $failing_obj_ids) {
206  return $this->createObjectInterfaceMock($ref_id, $failing_obj_ids);
207  });
208 
209  // Configure the delete method
210  $mock->method('delete')
211  ->willReturnCallback(function () use ($ref_id, $failing_obj_ids) {
212  if (in_array($ref_id, $failing_obj_ids)) {
213  throw new \Exception("Failed to do something");
214  }
215  $this->deleted_ref_ids[] = $ref_id;
216  });
217 
218  // Configure the getId method
219  $mock->method('getId')
220  ->willReturnCallback(function () use ($ref_id) {
221  return $ref_id;
222  });
223 
224  // Configure the getType method
225  $mock->method('getType')
226  ->willReturn('tst');
227 
228  // Configure the getTitle method
229  $mock->method('getTitle')
230  ->willReturn('Sample Object Title');
231 
232  // Configure the getRefId method
233  $mock->method('getRefId')
234  ->willReturnCallback(function () use ($ref_id) {
235  return $ref_id;
236  });
237 
238  return $mock;
239  }
createObjectInterfaceMock(int $ref_id, array $failing_obj_ids=[])
$ref_id
Definition: ltiauth.php:66
+ Here is the caller graph for this function:

◆ createPermissionInterfaceMock()

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

Definition at line 169 of file DeletionTest.php.

References $ref_id.

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

171  : PermissionInterface {
172  // Create the mock object
173  $mock = $this->createMock(PermissionInterface::class);
174 
175  // Configure the checkAccess method to return true or false based on operation and ref_id
176  $mock->method('checkAccess')
177  ->willReturnCallback(function (string $operation, int $ref_id) use ($access_given) {
178  return $access_given;
179  });
180 
181  // Configure the revokePermission method
182  $mock->method('revokePermission')
183  ->willReturnCallback(function (int $ref_id) {
184  });
185 
186  // Configure the getRefIdsWithoutDeletePermission method to return a filtered list of ids
187  $mock->method('getRefIdsWithoutDeletePermission')
188  ->willReturnCallback(function (array $ids) use ($access_given) {
189  if ($access_given) {
190  return [];
191  }
192  return $ids;
193  });
194 
195  return $mock;
196  }
$ref_id
Definition: ltiauth.php:66
+ Here is the caller graph for this function:

◆ createTreeInterfaceMock()

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

Definition at line 65 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().

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

302  : Deletion {
303  return new Deletion(
304  $tree_mock,
305  $this->createPermissionInterfaceMock($access_given),
306  $this->createEventInterfaceMock(),
307  $this->createObjectInterfaceMock(0, $failing_obj_ids),
308  $trash_enabled
309  );
310  }
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 40 of file DeletionTest.php.

40  : void
41  {
42  parent::setUp();
43  }

◆ tearDown()

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

Definition at line 311 of file DeletionTest.php.

311  : void
312  {
313  }

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

441  : void
442  {
443  $this->loadTreeData(1);
444  $this->resetDeleteRefIds();
445  $tree_mock = $this->createTreeInterfaceMock(1);
446  $deletion = $this->initDeletion(
447  $tree_mock,
448  true,
449  true
450  );
451 
452  // delete tree 2
453  $deletion->deleteObjectsByRefIds([2]);
454 
455  $deletion->removeObjectsFromSystemByRefIds([2]);
456 
457  // 2 is not in trash
458  $this->assertEquals(false, $tree_mock->isDeleted(2));
459 
460  // no left trashed subtrees
461  $this->assertEquals([], $tree_mock->getTrashedSubtrees(1));
462 
463  // 2,4 have been deleted
464  $this->assertEquals([2,4], $this->deleted_ref_ids);
465  }
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 408 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().

408  : void
409  {
410  $this->loadTreeData(1);
411  $this->resetDeleteRefIds();
412  $tree_mock = $this->createTreeInterfaceMock(1);
413  $deletion = $this->initDeletion(
414  $tree_mock,
415  false,
416  true
417  );
418 
419  // delete tree 2
420  $deletion->deleteObjectsByRefIds([2]);
421 
422  // tree is not in trash
423  $this->assertEquals(false, $tree_mock->isDeleted(2));
424 
425  // no trashed subtrees
426  $this->assertEquals([], $tree_mock->getTrashedSubtrees(1));
427 
428  // 2 has been deleted
429  $this->assertEquals([2,4], $this->deleted_ref_ids);
430  }
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 349 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().

349  : void
350  {
351  $this->loadTreeData(1);
352  $this->resetDeleteRefIds();
353  $tree_mock = $this->createTreeInterfaceMock(1);
354  $deletion = $this->initDeletion(
355  $tree_mock,
356  true,
357  true
358  );
359 
360  $deletion->deleteObjectsByRefIds([2]);
361  $this->assertEquals(true, $tree_mock->isDeleted(2));
362 
363  $this->assertEquals([-2], $tree_mock->getTrashedSubtrees(1));
364 
365  // nothing has been finally deleted
366  $this->assertEquals([], $this->deleted_ref_ids);
367  }
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 378 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().

378  : void
379  {
380  $this->loadTreeData(1);
381  $this->resetDeleteRefIds();
382  $tree_mock = $this->createTreeInterfaceMock(1);
383  $deletion = $this->initDeletion(
384  $tree_mock,
385  true,
386  true
387  );
388 
389  $deletion->deleteObjectsByRefIds([2]);
390  $deletion->deleteObjectsByRefIds([3]);
391  $this->assertEquals(true, $tree_mock->isDeleted(2));
392  $this->assertEquals(true, $tree_mock->isDeleted(3));
393 
394  $this->assertEquals([-2, -3], $tree_mock->getTrashedSubtrees(1));
395 
396  // nothing has been finally deleted
397  $this->assertEquals([], $this->deleted_ref_ids);
398  }
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 327 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().

327  : void
328  {
329  $this->loadTreeData(1);
330  $this->resetDeleteRefIds();
331  $tree_mock = $this->createTreeInterfaceMock(1);
332  $deletion = $this->initDeletion(
333  $tree_mock,
334  true,
335  true
336  );
337 
338  static::assertInstanceOf(Deletion::class, $deletion);
339  }
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 707 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().

707  : void
708  {
709  $this->log(PHP_EOL . "---testDeletionNoDeletePermission");
710  $this->loadTreeData(1);
711  $this->resetDeleteRefIds();
712  $tree_mock = $this->createTreeInterfaceMock(1);
713  $deletion = $this->initDeletion(
714  $tree_mock,
715  true,
716  false,
717  [8]
718  );
719 
720  $this->log("---call: deleteObjectsByRefIds 9");
721  $this->expectException(MissingPermissionException::class);
722  $deletion->deleteObjectsByRefIds([9]);
723 
724  // 9 not in trash
725  $this->assertEquals(false, $tree_mock->isDeleted(9));
726 
727  // no trashed subtrees
728  $this->assertEquals([], $tree_mock->getTrashedSubtrees(1));
729  $this->assertEquals([], $tree_mock->getTrashedSubtrees(2));
730 
731  // nothing deleted
732  $this->assertEqualsCanonicalizing([], $this->deleted_ref_ids);
733  $this->log("---END---testDeletionNoDeletePermission");
734  }
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 521 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().

521  : void
522  {
523  $this->log(PHP_EOL . "---testDeletionDeleteRemoveFromSystemMultiple");
524  $this->loadTreeData(1);
525  $this->resetDeleteRefIds();
526  $tree_mock = $this->createTreeInterfaceMock(1);
527  $deletion = $this->initDeletion(
528  $tree_mock,
529  true,
530  true
531  );
532 
533  // delete tree 2
534  $this->log("---call: deleteObjectsByRefIds 8");
535  $deletion->deleteObjectsByRefIds([8]);
536  $this->log("---call: deleteObjectsByRefIds 3");
537  $deletion->deleteObjectsByRefIds([3]);
538 
539  $this->log("---call: removeObjectsFromSystemByRefIds 3");
540  $deletion->removeObjectsFromSystemByRefIds([3]);
541 
542  // 3,5,6,7,8 are not in trash
543  $this->assertEquals(false, $tree_mock->isDeleted(3));
544  $this->assertEquals(false, $tree_mock->isDeleted(5));
545  $this->assertEquals(false, $tree_mock->isDeleted(6));
546  $this->assertEquals(false, $tree_mock->isDeleted(7));
547  $this->assertEquals(false, $tree_mock->isDeleted(8));
548  $this->assertEquals(false, $tree_mock->isDeleted(9));
549 
550  // no left trashed subtrees
551  $this->assertEquals([], $tree_mock->getTrashedSubtrees(1));
552  $this->assertEquals([], $tree_mock->getTrashedSubtrees(2));
553 
554  // 3,5,6,7,8,9 have been deleted
555  $this->assertEqualsCanonicalizing([3,5,6,7,8,9], $this->deleted_ref_ids);
556  $this->log("---END---testDeletionDeleteRemoveFromSystemMultiple");
557  }
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 615 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().

615  : void
616  {
617  $this->log(PHP_EOL . "---testDeletionRemoveFromSystemFailingObject");
618  $this->loadTreeData(1);
619  $this->resetDeleteRefIds();
620  $tree_mock = $this->createTreeInterfaceMock(1);
621  $deletion = $this->initDeletion(
622  $tree_mock,
623  true,
624  true,
625  [8]
626  );
627 
628  $this->log("---call: deleteObjectsByRefIds 9");
629  $deletion->deleteObjectsByRefIds([9]);
630  $this->log("---call: deleteObjectsByRefIds 8");
631  $deletion->deleteObjectsByRefIds([8]);
632  $this->log("---call: deleteObjectsByRefIds 3");
633  $deletion->deleteObjectsByRefIds([3]);
634 
635  $this->log("---call: removeObjectsFromSystemByRefIds 3");
636  $deletion->removeObjectsFromSystemByRefIds([3]);
637 
638  // 3,5,6,7,8 are not in trash
639  $this->assertEquals(false, $tree_mock->isDeleted(3));
640  $this->assertEquals(false, $tree_mock->isDeleted(5));
641  $this->assertEquals(false, $tree_mock->isDeleted(6));
642  $this->assertEquals(false, $tree_mock->isDeleted(7));
643  $this->assertEquals(false, $tree_mock->isDeleted(8));
644  $this->assertEquals(false, $tree_mock->isDeleted(9));
645 
646  // no left trashed subtrees
647  $this->assertEquals([], $tree_mock->getTrashedSubtrees(1));
648  $this->assertEquals([], $tree_mock->getTrashedSubtrees(2));
649 
650  // 3,5,6,7,8,9 have been deleted
651  $this->assertEqualsCanonicalizing([3,5,6,7,9], $this->deleted_ref_ids);
652  $this->log("---END---testDeletionRemoveFromSystemFailingObject");
653  }
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 475 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().

475  : void
476  {
477  $this->log(PHP_EOL . "---testDeletionDeleteRemoveFromSystemMultiple");
478  $this->loadTreeData(1);
479  $this->resetDeleteRefIds();
480  $tree_mock = $this->createTreeInterfaceMock(1);
481  $deletion = $this->initDeletion(
482  $tree_mock,
483  true,
484  true
485  );
486 
487  // delete tree 2
488  $this->log("---call: deleteObjectsByRefIds 6");
489  $deletion->deleteObjectsByRefIds([6]);
490  $this->log("---call: deleteObjectsByRefIds 3");
491  $deletion->deleteObjectsByRefIds([3]);
492 
493  $this->log("---call: removeObjectsFromSystemByRefIds 3");
494  $deletion->removeObjectsFromSystemByRefIds([3]);
495 
496  // 3,5,6,7,8 are not in trash
497  $this->assertEquals(false, $tree_mock->isDeleted(3));
498  $this->assertEquals(false, $tree_mock->isDeleted(5));
499  $this->assertEquals(false, $tree_mock->isDeleted(6));
500  $this->assertEquals(false, $tree_mock->isDeleted(7));
501  $this->assertEquals(false, $tree_mock->isDeleted(8));
502  $this->assertEquals(false, $tree_mock->isDeleted(9));
503 
504  // no left trashed subtrees
505  $this->assertEquals([], $tree_mock->getTrashedSubtrees(1));
506  $this->assertEquals([], $tree_mock->getTrashedSubtrees(2));
507 
508  // 3,5,6,7,8 have been deleted
509  $this->assertEqualsCanonicalizing([3,5,6,7,8,9], $this->deleted_ref_ids);
510  $this->log("---END---testDeletionDeleteRemoveFromSystemMultiple");
511  }
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 568 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().

568  : void
569  {
570  $this->log(PHP_EOL . "---testDeletionRemoveFromSystemTrashInTrash");
571  $this->loadTreeData(1);
572  $this->resetDeleteRefIds();
573  $tree_mock = $this->createTreeInterfaceMock(1);
574  $deletion = $this->initDeletion(
575  $tree_mock,
576  true,
577  true
578  );
579 
580  $this->log("---call: deleteObjectsByRefIds 9");
581  $deletion->deleteObjectsByRefIds([9]);
582  $this->log("---call: deleteObjectsByRefIds 8");
583  $deletion->deleteObjectsByRefIds([8]);
584  $this->log("---call: deleteObjectsByRefIds 3");
585  $deletion->deleteObjectsByRefIds([3]);
586 
587  $this->log("---call: removeObjectsFromSystemByRefIds 3");
588  $deletion->removeObjectsFromSystemByRefIds([3]);
589 
590  // 3,5,6,7,8 are not in trash
591  $this->assertEquals(false, $tree_mock->isDeleted(3));
592  $this->assertEquals(false, $tree_mock->isDeleted(5));
593  $this->assertEquals(false, $tree_mock->isDeleted(6));
594  $this->assertEquals(false, $tree_mock->isDeleted(7));
595  $this->assertEquals(false, $tree_mock->isDeleted(8));
596  $this->assertEquals(false, $tree_mock->isDeleted(9));
597 
598  // no left trashed subtrees
599  $this->assertEquals([], $tree_mock->getTrashedSubtrees(1));
600  $this->assertEquals([], $tree_mock->getTrashedSubtrees(2));
601 
602  // 3,5,6,7,8,9 have been deleted
603  $this->assertEqualsCanonicalizing([3,5,6,7,8,9], $this->deleted_ref_ids);
604  $this->log("---END---testDeletionRemoveFromSystemTrashInTrash");
605  }
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 665 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().

665  : void
666  {
667  $this->log(PHP_EOL . "---testDeletionRemoveFromSystemTrashInTrashInTrash");
668  $this->loadTreeData(1);
669  $this->resetDeleteRefIds();
670  $tree_mock = $this->createTreeInterfaceMock(1);
671  $deletion = $this->initDeletion(
672  $tree_mock,
673  true,
674  true,
675  [8]
676  );
677 
678  $this->log("---call: deleteObjectsByRefIds 9");
679  $deletion->deleteObjectsByRefIds([9]);
680  $this->log("---call: deleteObjectsByRefIds 8");
681  $deletion->deleteObjectsByRefIds([8]);
682  $this->log("---call: deleteObjectsByRefIds 6");
683  $deletion->deleteObjectsByRefIds([6]);
684  $this->log("---call: deleteObjectsByRefIds 3");
685  $deletion->deleteObjectsByRefIds([3]);
686 
687  $this->log("---call: removeObjectsFromSystemByRefIds 3");
688  $deletion->removeObjectsFromSystemByRefIds([3]);
689 
690  // 3,5,6,7,8 are not in trash
691  $this->assertEquals(false, $tree_mock->isDeleted(3));
692  $this->assertEquals(false, $tree_mock->isDeleted(5));
693  $this->assertEquals(false, $tree_mock->isDeleted(6));
694  $this->assertEquals(false, $tree_mock->isDeleted(7));
695  $this->assertEquals(false, $tree_mock->isDeleted(8));
696  $this->assertEquals(false, $tree_mock->isDeleted(9));
697 
698  // no left trashed subtrees
699  $this->assertEquals([], $tree_mock->getTrashedSubtrees(1));
700  $this->assertEquals([], $tree_mock->getTrashedSubtrees(2));
701 
702  // 3,5,6,7,8,9 have been deleted
703  $this->assertEqualsCanonicalizing([3,5,6,7,9], $this->deleted_ref_ids);
704  $this->log("---END---testDeletionRemoveFromSystemTrashInTrashInTrash");
705  }
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 745 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().

745  : void
746  {
747  $this->log(PHP_EOL . "---testDeletionTrashDisabledTrashInTrashInTrash");
748  $this->loadTreeData(1);
749  $this->resetDeleteRefIds();
750  $tree_mock = $this->createTreeInterfaceMock(1);
751  $deletion = $this->initDeletion(
752  $tree_mock,
753  false,
754  true,
755  []
756  );
757 
758  $this->log("---call: deleteObjectsByRefIds 9");
759  $deletion->deleteObjectsByRefIds([9]);
760  $this->log("---call: deleteObjectsByRefIds 8");
761  $deletion->deleteObjectsByRefIds([8]);
762  $this->log("---call: deleteObjectsByRefIds 6");
763  $deletion->deleteObjectsByRefIds([6]);
764  $this->log("---call: deleteObjectsByRefIds 3");
765  $deletion->deleteObjectsByRefIds([3]);
766 
767  // 3,5,6,7,8,9 are not in trash
768  $this->assertEquals(false, $tree_mock->isDeleted(3));
769  $this->assertEquals(false, $tree_mock->isDeleted(5));
770  $this->assertEquals(false, $tree_mock->isDeleted(6));
771  $this->assertEquals(false, $tree_mock->isDeleted(7));
772  $this->assertEquals(false, $tree_mock->isDeleted(8));
773  $this->assertEquals(false, $tree_mock->isDeleted(9));
774 
775  // no left trashed subtrees
776  $this->assertEquals([], $tree_mock->getTrashedSubtrees(1));
777  $this->assertEquals([], $tree_mock->getTrashedSubtrees(2));
778 
779  // 3,5,6,7,8,9 have been deleted
780  $this->assertEqualsCanonicalizing([3,5,6,7,8,9], $this->deleted_ref_ids);
781  $this->log("---END---testDeletionTrashDisabledTrashInTrashInTrash");
782  }
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 315 of file DeletionTest.php.

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

315  : void
316  {
317  $this->loadTreeData(1);
318  $tree_mock = $this->createTreeInterfaceMock(1);
319 
320  $node1 = $tree_mock->getNodeData(1);
321  $this->assertEquals(0, $node1["parent"]);
322 
323  $tree_mock->moveToTrash(2);
324  $this->assertEquals(true, $tree_mock->isDeleted(2));
325  }
+ 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 38 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 9 of file DeletionTest.php.

◆ $tree_data

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

Definition at line 36 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 23 of file DeletionTest.php.


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