ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
DeletionTest.php
Go to the documentation of this file.
1 <?php
2 
4 
6 
7 class DeletionTest extends TestCase
8 {
9  protected array $test_tree_data = [
10  1 => [ // data id
11  1 => [ // tree id
23  1 => ["tree" => 1, "child" => 1, "ref_id" => 1, "obj_id" => 1, "parent" => 0],
24  2 => ["tree" => 1, "child" => 2, "ref_id" => 2, "obj_id" => 2, "parent" => 1],
25  3 => ["tree" => 1, "child" => 3, "ref_id" => 3, "obj_id" => 3, "parent" => 1],
26  4 => ["tree" => 1, "child" => 4, "ref_id" => 4, "obj_id" => 4, "parent" => 2],
27  5 => ["tree" => 1, "child" => 5, "ref_id" => 5, "obj_id" => 5, "parent" => 3],
28  6 => ["tree" => 1, "child" => 6, "ref_id" => 6, "obj_id" => 6, "parent" => 3],
29  7 => ["tree" => 1, "child" => 7, "ref_id" => 7, "obj_id" => 7, "parent" => 6],
30  8 => ["tree" => 1, "child" => 8, "ref_id" => 8, "obj_id" => 8, "parent" => 6],
31  9 => ["tree" => 1, "child" => 9, "ref_id" => 9, "obj_id" => 9, "parent" => 8],
32  ]
33  ]
34  ];
35 
36  protected array $tree_data = [];
37 
38  protected array $deleted_ref_ids = [];
39 
40  protected function setUp(): void
41  {
42  parent::setUp();
43  }
44 
45  public function loadTreeData(int $data_id): void
46  {
47  $this->tree_data = $this->test_tree_data[$data_id];
48  }
49 
50  public function resetDeleteRefIds(): void
51  {
52  $this->deleted_ref_ids = [];
53  }
54 
55  protected function addChilds($id, &$childs, $data): 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  }
64 
65  public function createTreeInterfaceMock(int $tree_id): 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  }
168 
170  bool $access_given
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  }
197 
198  public function createObjectInterfaceMock(int $ref_id, array $failing_obj_ids = []): 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  }
240 
241  protected function log(string $message): void
242  {
243  $log = false;
244  if ($log) {
245  echo $message . PHP_EOL;
246  }
247  }
248 
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  }
296 
297  public function initDeletion(
298  TreeInterface $tree_mock = null,
299  bool $trash_enabled = true,
300  bool $access_given = true,
301  array $failing_obj_ids = []
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  }
311  protected function tearDown(): void
312  {
313  }
314 
315  public function testTreeMockTest(): 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  }
326 
327  public function testDeletionInstantiation(): 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  }
340 
349  public function testDeletionDeleteWithTrash(): 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  }
368 
378  public function testDeletionDeleteWithTrashMultiple(): 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  }
399 
408  public function testDeletionDeleteWithoutTrash(): 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  }
431 
441  public function testDeletionDeleteRemoveFromSystem(): 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  }
466 
475  public function testDeletionRemoveFromSystemMultiple(): 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  }
512 
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  }
558 
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  }
606 
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  }
654 
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  }
706 
707  public function testDeletionNoDeletePermission(): 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  }
735 
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  }
783 
784 }
createObjectInterfaceMock(int $ref_id, array $failing_obj_ids=[])
initDeletion(TreeInterface $tree_mock=null, bool $trash_enabled=true, bool $access_given=true, array $failing_obj_ids=[])
$c
Definition: deliver.php:9
$ref_id
Definition: ltiauth.php:66
createPermissionInterfaceMock(bool $access_given)
$log
Definition: ltiresult.php:34
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:24