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],
    40     protected function setUp(): void
    47         $this->tree_data = $this->test_tree_data[$data_id];
    52         $this->deleted_ref_ids = [];
    58             if (
$c[
"parent"] == 
$id) {
    67         $mock = $this->createMock(TreeInterface::class);
    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);
    81         $mock->method(
'getNodeData')
    82              ->willReturnCallback(
function (
int $child) use ($tree_id) {
    83                  return $this->tree_data[$tree_id][$child];
    86         $mock->method(
'useCache')
    87              ->willReturnCallback(
function (
bool $a_use) {
    91         $mock->method(
'getSubTree')
    92              ->willReturnCallback(
function (array $node) use ($tree_id) {
    93                  $childs[$node[
"child"]] = $node;
    94                  $data = $this->tree_data[$tree_id];
   100         $mock->method(
'getDeletedTreeNodeIds')
   101              ->willReturnCallback(
function (array $ids) use ($mock) {
   103                  foreach ($ids as 
$id) {
   104                      if ($mock->isDeleted($id)) {
   105                          $deleted_ids[] = 
$id;
   112         $mock->method(
'getTree')
   113              ->willReturnCallback(
function (
int $tree_id) {
   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);
   128         $mock->method(
'moveToTrash')
   129              ->willReturnCallback(
function (
int $child) use ($mock, $tree_id) {
   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;
   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"]]);
   151         $mock->method(
'getTrashedSubtrees')
   152              ->willReturnCallback(
function (
int $ref_id) {
   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;
   173         $mock = $this->createMock(PermissionInterface::class);
   176         $mock->method(
'checkAccess')
   177              ->willReturnCallback(
function (
string $operation, 
int $ref_id) use ($access_given) {
   178                  return $access_given;
   182         $mock->method(
'revokePermission')
   183              ->willReturnCallback(
function (
int $ref_id) {
   187         $mock->method(
'getRefIdsWithoutDeletePermission')
   188              ->willReturnCallback(
function (array $ids) use ($access_given) {
   201         $mock = $this->createMock(ObjectInterface::class);
   204         $mock->method(
'getInstanceByRefId')
   205              ->willReturnCallback(
function (
int $ref_id) use ($mock, $failing_obj_ids) {
   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");
   215                  $this->deleted_ref_ids[] = 
$ref_id;
   219         $mock->method(
'getId')
   220             ->willReturnCallback(
function () use ($ref_id) {
   225         $mock->method(
'getType')
   229         $mock->method(
'getTitle')
   230              ->willReturn(
'Sample Object Title');
   233         $mock->method(
'getRefId')
   234              ->willReturnCallback(
function () use ($ref_id) {
   241     protected function log(
string $message): void
   245             echo $message . PHP_EOL;
   252         $mock = $this->createMock(EventInterface::class);
   255         $mock->method(
'beforeMoveToTrash')
   256              ->willReturnCallback(
function (
int $ref_id, array $subnodes) {
   257                  $this->
log(
'beforeMoveToTrash: ' . $ref_id);
   262         $mock->method(
'afterMoveToTrash')
   263              ->willReturnCallback(
function (
int $ref_id, 
int $old_parent_ref_id) {
   268         $mock->method(
'beforeSubtreeRemoval')
   269              ->willReturnCallback(
function (
int $obj_id) {
   270                  $this->
log(
'beforeSubtreeRemoval: ' . $obj_id);
   275         $mock->method(
'beforeObjectRemoval')
   276              ->willReturnCallback(
function (
int $obj_id, 
int $ref_id, 
string $type, 
string $title) {
   277                  $this->
log(
'beforeObjectRemoval: ' . $obj_id);
   282         $mock->method(
'afterObjectRemoval')
   283              ->willReturnCallback(
function (
int $obj_id, 
int $ref_id, 
string $type, 
int $old_parent_ref_id) {
   288         $mock->method(
'afterTreeDeletion')
   289              ->willReturnCallback(
function (
int $tree_id, 
int $child) {
   290                  $this->
log(
'afterTreeDeletion: ' . $tree_id . 
", " . $child);
   299         bool $trash_enabled = 
true,
   300         bool $access_given = 
true,
   301         array $failing_obj_ids = []
   320         $node1 = $tree_mock->getNodeData(1);
   321         $this->assertEquals(0, $node1[
"parent"]);
   323         $tree_mock->moveToTrash(2);
   324         $this->assertEquals(
true, $tree_mock->isDeleted(2));
   338         static::assertInstanceOf(Deletion::class, $deletion);
   360         $deletion->deleteObjectsByRefIds([2]);
   361         $this->assertEquals(
true, $tree_mock->isDeleted(2));
   363         $this->assertEquals([-2], $tree_mock->getTrashedSubtrees(1));
   366         $this->assertEquals([], $this->deleted_ref_ids);
   389         $deletion->deleteObjectsByRefIds([2]);
   390         $deletion->deleteObjectsByRefIds([3]);
   391         $this->assertEquals(
true, $tree_mock->isDeleted(2));
   392         $this->assertEquals(
true, $tree_mock->isDeleted(3));
   394         $this->assertEquals([-2, -3], $tree_mock->getTrashedSubtrees(1));
   397         $this->assertEquals([], $this->deleted_ref_ids);
   420         $deletion->deleteObjectsByRefIds([2]);
   423         $this->assertEquals(
false, $tree_mock->isDeleted(2));
   426         $this->assertEquals([], $tree_mock->getTrashedSubtrees(1));
   429         $this->assertEquals([2,4], $this->deleted_ref_ids);
   453         $deletion->deleteObjectsByRefIds([2]);
   455         $deletion->removeObjectsFromSystemByRefIds([2]);
   458         $this->assertEquals(
false, $tree_mock->isDeleted(2));
   461         $this->assertEquals([], $tree_mock->getTrashedSubtrees(1));
   464         $this->assertEquals([2,4], $this->deleted_ref_ids);
   477         $this->
log(PHP_EOL . 
"---testDeletionDeleteRemoveFromSystemMultiple");
   488         $this->
log(
"---call: deleteObjectsByRefIds 6");
   489         $deletion->deleteObjectsByRefIds([6]);
   490         $this->
log(
"---call: deleteObjectsByRefIds 3");
   491         $deletion->deleteObjectsByRefIds([3]);
   493         $this->
log(
"---call: removeObjectsFromSystemByRefIds 3");
   494         $deletion->removeObjectsFromSystemByRefIds([3]);
   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));
   505         $this->assertEquals([], $tree_mock->getTrashedSubtrees(1));
   506         $this->assertEquals([], $tree_mock->getTrashedSubtrees(2));
   509         $this->assertEqualsCanonicalizing([3,5,6,7,8,9], $this->deleted_ref_ids);
   510         $this->
log(
"---END---testDeletionDeleteRemoveFromSystemMultiple");
   523         $this->
log(PHP_EOL . 
"---testDeletionDeleteRemoveFromSystemMultiple");
   534         $this->
log(
"---call: deleteObjectsByRefIds 8");
   535         $deletion->deleteObjectsByRefIds([8]);
   536         $this->
log(
"---call: deleteObjectsByRefIds 3");
   537         $deletion->deleteObjectsByRefIds([3]);
   539         $this->
log(
"---call: removeObjectsFromSystemByRefIds 3");
   540         $deletion->removeObjectsFromSystemByRefIds([3]);
   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));
   551         $this->assertEquals([], $tree_mock->getTrashedSubtrees(1));
   552         $this->assertEquals([], $tree_mock->getTrashedSubtrees(2));
   555         $this->assertEqualsCanonicalizing([3,5,6,7,8,9], $this->deleted_ref_ids);
   556         $this->
log(
"---END---testDeletionDeleteRemoveFromSystemMultiple");
   570         $this->
log(PHP_EOL . 
"---testDeletionRemoveFromSystemTrashInTrash");
   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]);
   587         $this->
log(
"---call: removeObjectsFromSystemByRefIds 3");
   588         $deletion->removeObjectsFromSystemByRefIds([3]);
   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));
   599         $this->assertEquals([], $tree_mock->getTrashedSubtrees(1));
   600         $this->assertEquals([], $tree_mock->getTrashedSubtrees(2));
   603         $this->assertEqualsCanonicalizing([3,5,6,7,8,9], $this->deleted_ref_ids);
   604         $this->
log(
"---END---testDeletionRemoveFromSystemTrashInTrash");
   617         $this->
log(PHP_EOL . 
"---testDeletionRemoveFromSystemFailingObject");
   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]);
   635         $this->
log(
"---call: removeObjectsFromSystemByRefIds 3");
   636         $deletion->removeObjectsFromSystemByRefIds([3]);
   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));
   647         $this->assertEquals([], $tree_mock->getTrashedSubtrees(1));
   648         $this->assertEquals([], $tree_mock->getTrashedSubtrees(2));
   651         $this->assertEqualsCanonicalizing([3,5,6,7,9], $this->deleted_ref_ids);
   652         $this->
log(
"---END---testDeletionRemoveFromSystemFailingObject");
   667         $this->
log(PHP_EOL . 
"---testDeletionRemoveFromSystemTrashInTrashInTrash");
   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]);
   687         $this->
log(
"---call: removeObjectsFromSystemByRefIds 3");
   688         $deletion->removeObjectsFromSystemByRefIds([3]);
   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));
   699         $this->assertEquals([], $tree_mock->getTrashedSubtrees(1));
   700         $this->assertEquals([], $tree_mock->getTrashedSubtrees(2));
   703         $this->assertEqualsCanonicalizing([3,5,6,7,9], $this->deleted_ref_ids);
   704         $this->
log(
"---END---testDeletionRemoveFromSystemTrashInTrashInTrash");
   709         $this->
log(PHP_EOL . 
"---testDeletionNoDeletePermission");
   720         $this->
log(
"---call: deleteObjectsByRefIds 9");
   721         $this->expectException(MissingPermissionException::class);
   722         $deletion->deleteObjectsByRefIds([9]);
   725         $this->assertEquals(
false, $tree_mock->isDeleted(9));
   728         $this->assertEquals([], $tree_mock->getTrashedSubtrees(1));
   729         $this->assertEquals([], $tree_mock->getTrashedSubtrees(2));
   732         $this->assertEqualsCanonicalizing([], $this->deleted_ref_ids);
   733         $this->
log(
"---END---testDeletionNoDeletePermission");
   747         $this->
log(PHP_EOL . 
"---testDeletionTrashDisabledTrashInTrashInTrash");
   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]);
   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));
   776         $this->assertEquals([], $tree_mock->getTrashedSubtrees(1));
   777         $this->assertEquals([], $tree_mock->getTrashedSubtrees(2));
   780         $this->assertEqualsCanonicalizing([3,5,6,7,8,9], $this->deleted_ref_ids);
   781         $this->
log(
"---END---testDeletionTrashDisabledTrashInTrashInTrash");
 testDeletionDeleteWithTrash()
 
createTreeInterfaceMock(int $tree_id)
 
testDeletionRemoveFromSystemTrashInTrash()
 
testDeletionRemoveFromSystemMultiple()
 
testDeletionTrashDisabledTrashInTrashInTrash()
 
testDeletionRemoveFromSystemTrashInTrashInTrash()
 
createObjectInterfaceMock(int $ref_id, array $failing_obj_ids=[])
 
testDeletionDeleteWithoutTrash()
 
testDeletionDeleteWithTrashMultiple()
 
initDeletion(TreeInterface $tree_mock=null, bool $trash_enabled=true, bool $access_given=true, array $failing_obj_ids=[])
 
testDeletionInstantiation()
 
createPermissionInterfaceMock(bool $access_given)
 
testDeletionRemoveFromSystemFailingObject()
 
loadTreeData(int $data_id)
 
testDeletionDeleteRemoveFromSystem()
 
testDeletionNoDeletePermission()
 
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins 
 
addChilds($id, &$childs, $data)
 
createEventInterfaceMock()
 
testDeletionRemoveFromSystemDeepSubtree()