ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ManipulatorTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
68 
69 class ManipulatorTest extends TestCase
70 {
71  protected function getSetMock(ElementInterface $set_root): SetInterface
72  {
73  return new class ($set_root) extends NullSet {
74  public function __construct(protected ElementInterface $set_root)
75  {
76  }
77 
78  public function getRessourceID(): RessourceIDInterface
79  {
80  return new NullRessourceID();
81  }
82 
83  public function getRoot(): ElementInterface
84  {
85  return $this->set_root;
86  }
87  };
88  }
89 
91  {
92  return new class () extends NullScaffoldProvider {
93  public function getScaffoldsForElement(ElementInterface $element): \Generator
94  {
95  yield from [];
96  }
97  };
98  }
99 
100  public function getMarkerMock(Action $action, string $data_value = ''): MarkerInterface
101  {
102  return new class ($action, $data_value) extends NullMarker {
103  public function __construct(protected Action $action, protected string $data_value)
104  {
105  }
106 
107  public function action(): Action
108  {
109  return $this->action;
110  }
111 
112  public function dataValue(): string
113  {
114  return $this->data_value;
115  }
116  };
117  }
118 
120  {
121  return new class ($this) extends NullMarkerFactory {
122  public function __construct(protected ManipulatorTest $test)
123  {
124  }
125 
126  public function marker(Action $action, string $data_value = ''): MarkerInterface
127  {
128  return $this->test->getMarkerMock($action, $data_value);
129  }
130  };
131  }
132 
133  public function getNavigatorMock(PathInterface $path, ElementInterface $start_element): NavigatorInterface
134  {
135  return new class ($path, $start_element) extends NullNavigator {
139  protected array $my_elements;
143  protected array $steps;
144  protected int $step_index;
145 
146  public function __construct(PathInterface $path, protected ElementInterface $start_element)
147  {
148  $this->my_elements = [$this->start_element];
149  $this->steps = iterator_to_array($path->steps());
150  $this->step_index = -1;
151  }
152 
153  protected function filterElements(): void
154  {
155  foreach ($this->currentStep()->filters() as $filter) {
156  if ($filter->type() === FilterType::NULL) {
157  continue;
158  }
159  if ($filter->type() === FilterType::MDID) {
160  $elements = [];
161  foreach ($this->my_elements as $element) {
162  foreach ($filter->values() as $value) {
163  if ($element->getMDID() === $value) {
164  $elements[] = $element;
165  break;
166  }
167  }
168  }
169  $this->my_elements = $elements;
170  continue;
171  }
172  if ($filter->type() === FilterType::DATA) {
173  $elements = [];
174  foreach ($this->my_elements as $element) {
175  foreach ($filter->values() as $value) {
176  if ($element->getData()->value() === $value) {
177  $elements[] = $element;
178  break;
179  }
180  }
181  }
182  $this->my_elements = $elements;
183  continue;
184  }
185  if ($filter->type() === FilterType::INDEX) {
186  $elements = [];
187  foreach ($filter->values() as $value) {
188  $value = (int) $value;
189  if (0 <= $value && $value < count($this->my_elements)) {
190  $elements[] = $this->my_elements[$value];
191  }
192  }
193  $this->my_elements = $elements;
194  }
195  }
196  }
197 
198  public function elementsAtFinalStep(): \Generator
199  {
200  $current = clone $this;
201  while ($current->hasNextStep()) {
202  $current = $current->nextStep();
203  }
204  yield from $current->my_elements;
205  }
206 
207  public function lastElement(): ?ElementInterface
208  {
209  $element_count = count($this->my_elements);
210  return ($element_count === 0) ? null : $this->my_elements[$element_count - 1];
211  }
212 
213  public function nextStep(): ?NavigatorInterface
214  {
215  if (!$this->hasNextStep()) {
216  return null;
217  }
218  $clone = clone $this;
219  $clone->my_elements = [];
220  $clone->step_index = $clone->step_index + 1;
221  foreach ($this->my_elements as $element) {
222  array_push($clone->my_elements, ...$element->getSubElements());
223  }
224  $clone->filterElements();
225  return $clone;
226  }
227 
228  public function currentStep(): ?StepInterface
229  {
230  return (0 <= $this->step_index && $this->step_index < count($this->steps)) ? $this->steps[$this->step_index] : null;
231  }
232 
233  public function lastElementAtFinalStep(): ?ElementInterface
234  {
235  $final_elements = iterator_to_array($this->elementsAtFinalStep());
236  $final_elements_count = count($final_elements);
237  return $final_elements_count > 0 ? $final_elements[$final_elements_count - 1] : null;
238  }
239 
240  public function previousStep(): ?NavigatorInterface
241  {
242  if (!$this->hasPreviousStep()) {
243  return null;
244  }
245  $clone = clone $this;
246  $clone->my_elements = [];
247  $clone->step_index = $clone->step_index - 1;
248  foreach ($this->my_elements as $element) {
249  $clone->my_elements[] = $element->getSuperElement();
250  }
251  return $clone;
252  }
253 
254  public function hasNextStep(): bool
255  {
256  return ($this->step_index + 1) < count($this->steps);
257  }
258 
259  public function hasPreviousStep(): bool
260  {
261  return ($this->step_index - 1) >= -1;
262  }
263 
264  public function hasElements(): bool
265  {
266  return count($this->my_elements) > 0;
267  }
268 
269  public function elements(): \Generator
270  {
271  yield from $this->my_elements;
272  }
273  };
274  }
275 
276  public function getPathConditionCollectionMock(PathInterface $path): PathConditionsCollectionInterface
277  {
282  $path_conditions = [];
283  $collected_steps = [];
284  $name = '';
285  foreach ($path->steps() as $step) {
286  if ($step->name() === StepToken::SUPER) {
287  $super = $step;
288  $condition = array_pop($collected_steps);
289  $target = $collected_steps[count($collected_steps) - 1];
290  $condition_path_steps = [$condition];
291 
292  if (key_exists($condition->name(), $path_conditions)) {
293  // array_pop($condition_path_steps);
294  foreach ($path_conditions[$condition->name()]->steps() as $cond_step) {
295  $condition_path_steps[] = $cond_step;
296  }
297  // $condition_path_steps[] = $super;
298  unset($path_conditions[$condition->name()]);
299  }
300 
301  if (key_exists($target->name(), $path_conditions)) {
302  $target_steps = [];
303  foreach ($path_conditions[$target->name()]->steps() as $cond_step) {
304  $target_steps[] = $cond_step;
305  }
306  array_unshift($condition_path_steps, ...$target_steps);
307  unset($path_conditions[$target->name()]);
308  }
309 
310  $path_conditions[$target->name()] = $this->getPathMock(
311  $condition_path_steps,
312  true,
313  false
314  );
315  continue;
316  }
317  $collected_steps[] = $step;
318  }
319 
320  return new class (
321  $this,
322  $this->getPathMock($collected_steps, false, false),
323  $path_conditions
324  ) extends NullPathConditionsCollection {
325  public function __construct(
326  protected ManipulatorTest $test,
327  protected PathInterface $clear_path,
328  protected array $path_conditons
329  ) {
330  }
331 
332  public function getPathWithoutConditions(): PathInterface
333  {
334  return $this->clear_path;
335  }
336 
337  public function getConditionPathByStepName(string $name): PathInterface
338  {
339  if (key_exists($name, $this->path_conditons)) {
340  return $this->path_conditons[$name];
341  }
342  return $this->test->getPathMock([], true, false);
343  }
344  };
345  }
346 
348  PathConditionsCollectionInterface $path_conditions_collection
350  return new class (
351  $path_conditions_collection,
352  $this->getNavigatorFactoryMock()
353  ) extends NullPathConditionsChecker {
354  public function __construct(
355  protected PathConditionsCollectionInterface $path_conditions_collection,
356  protected NavigatorFactoryInterface $navigator_factory
357  ) {
358  }
359 
360  public function isPathConditionMet(StepInterface $step, ElementInterface $root): bool
361  {
362  $navigator = $this->navigator_factory->navigator(
363  $this->path_conditions_collection->getConditionPathByStepName($step->name()),
364  $root
365  );
366  while (!is_null($navigator)) {
367  if (!$navigator->hasElements()) {
368  return false;
369  }
370  $navigator = $navigator->nextStep();
371  }
372  return true;
373  }
374 
375  public function allPathConditionsAreMet(StepInterface $step, ElementInterface ...$roots): bool
376  {
377  foreach ($roots as $root) {
378  if (!$this->isPathConditionMet($step, $root)) {
379  return false;
380  }
381  }
382  return true;
383  }
384 
385  public function atLeastOnePathConditionIsMet(StepInterface $step, ElementInterface ...$roots): bool
386  {
387  foreach ($roots as $root) {
388  if ($this->isPathConditionMet($step, $root)) {
389  return true;
390  }
391  }
392  return false;
393  }
394 
395  public function getRootsThatMeetPathCondition(StepInterface $step, ElementInterface ...$roots): \Generator
396  {
397  $elements = [];
398  foreach ($roots as $root) {
399  if ($this->isPathConditionMet($step, $root)) {
400  $elements[] = $root;
401  }
402  }
403  yield from $elements;
404  }
405  };
406  }
407 
409  {
410  return new class ($this) extends NullFactory {
411  public function __construct(protected ManipulatorTest $test)
412  {
413  }
414 
415  public function custom(): BuilderInterface
416  {
417  return $this->test->getPathBuilderMock();
418  }
419  };
420  }
421 
422  public function getPathBuilderMock(): BuilderInterface
423  {
424  return new class ($this) extends NullBuilder {
425  protected bool $is_relative;
426  protected bool $leads_to_exactly_one_element;
430  protected array $steps;
431 
432  public function __construct(protected ManipulatorTest $test)
433  {
434  $this->is_relative = false;
435  $this->leads_to_exactly_one_element = false;
436  }
437 
438  public function withLeadsToExactlyOneElement(bool $leads_to_one): BuilderInterface
439  {
440  $builder = clone $this;
441  $builder->leads_to_exactly_one_element = $leads_to_one;
442  return $builder;
443  }
444 
445  public function withRelative(bool $is_relative): BuilderInterface
446  {
447  $builder = clone $this;
448  $builder->is_relative = $is_relative;
449  return $builder;
450  }
451 
452  public function withNextStepFromStep(StepInterface $next_step, bool $add_as_first = false): BuilderInterface
453  {
454  $builder = clone $this;
455  $builder->steps[] = $next_step;
456  return $builder;
457  }
458 
459  public function get(): PathInterface
460  {
461  return $this->test->getPathMock($this->steps, $this->is_relative, $this->leads_to_exactly_one_element);
462  }
463  };
464  }
465 
467  {
468  return new class ($this) extends NullNavigatorFactory {
469  public function __construct(protected ManipulatorTest $test)
470  {
471  }
472 
473  public function navigator(PathInterface $path, ElementInterface $start_element): NavigatorInterface
474  {
475  return $this->test->getNavigatorMock($path, $start_element);
476  }
477  };
478  }
479 
481  {
482  return new class (
483  $this
484  ) extends NullPathUtilitiesFactory {
485  public function __construct(
486  protected ManipulatorTest $test
487  ) {
488  }
489 
490  public function pathConditionChecker(
491  PathConditionsCollectionInterface $path_conditions_collection
493  return $this->test->getPathConditionCheckerMock($path_conditions_collection);
494  }
495 
496  public function pathConditionsCollection(PathInterface $path): PathConditionsCollectionInterface
497  {
498  return $this->test->getPathConditionCollectionMock($path);
499  }
500  };
501  }
502 
503  public function getDataMock(string $value, Type $type): DataInterface
504  {
505  return new class ($value, $type) extends NullData {
506  public function __construct(protected string $my_value, protected Type $my_type)
507  {
508  }
509 
510  public function value(): string
511  {
512  return $this->my_value;
513  }
514 
515  public function type(): Type
516  {
517  return $this->my_type;
518  }
519  };
520  }
521 
522  public function getDefinitionMock(
523  string $name,
524  Type $data_type,
525  bool $is_unique
527  return new class ($name, $data_type, $is_unique) extends NullDefinition {
528  public function __construct(
529  protected string $my_name,
530  protected Type $data_type,
531  protected bool $is_unique
532  ) {
533  }
534 
535  public function name(): string
536  {
537  return $this->my_name;
538  }
539 
540  public function dataType(): Type
541  {
542  return $this->data_type;
543  }
544 
545  public function unique(): bool
546  {
547  return $this->is_unique;
548  }
549  };
550  }
551 
552  public function getElementMock(
553  int|NoID $mdid,
554  string $value,
555  Type $type,
556  bool $is_unique = false
557  ): ElementInterface {
558  return new class ($this, $mdid, $value, $type, $is_unique) extends NullElement {
559  protected ?ElementInterface $parent;
560  protected ?MarkerInterface $marker;
561  protected DataInterface $data;
562  protected DefinitionInterface $definition;
566  protected array $children;
567 
568  public function __construct(
569  protected ManipulatorTest $test,
570  protected int|NoID $mdid,
571  string $value,
572  Type $type,
573  bool $is_unique
574  ) {
575  $this->marker = null;
576  $this->parent = null;
577  $this->children = [];
578  $this->data = $this->test->getDataMock($value, $type);
579  $this->definition = $this->test->getDefinitionMock('', $this->data->type(), $is_unique);
580  }
581 
582  public function getMDID(): int|NoID
583  {
584  return $this->mdid;
585  }
586 
587  public function addChild(ElementInterface $child): void
588  {
589  $child->parent = $this;
590  $this->children[] = $child;
591  }
592 
593  public function addChildren(ElementInterface ...$children): void
594  {
595  foreach ($children as $child) {
596  $this->addChild($child);
597  }
598  }
599 
600  public function getSubElements(): \Generator
601  {
602  yield from $this->children;
603  }
604 
605  public function getSuperElement(): ?ElementInterface
606  {
607  return $this->parent;
608  }
609 
610  public function addScaffoldToSubElements(ScaffoldProviderInterface $scaffold_provider, string $name): ?ElementInterface
611  {
612  $element = $this->test->getElementMock(NoID::SCAFFOLD, $name, Type::NULL);
613  $this->addChild($element);
614  return $element;
615  }
616 
617  public function getData(): DataInterface
618  {
619  return $this->data;
620  }
621 
622  public function mark(MarkerFactoryInterface $factory, Action $action, string $data_value = ''): void
623  {
624  $this->marker = $factory->marker($action, $data_value);
625  $element = $this->parent;
626  while (!is_null($element) && !$element->isMarked()) {
627  $current_action = ($element->isScaffold() && $action === Action::CREATE_OR_UPDATE) ? Action::CREATE_OR_UPDATE : Action::NEUTRAL;
628  $element->marker = $factory->marker($current_action);
629  $element = $element->parent;
630  }
631  }
632 
633  public function getDefinition(): DefinitionInterface
634  {
635  return $this->definition;
636  }
637 
638 
639  public function getMarker(): ?MarkerInterface
640  {
641  return $this->marker;
642  }
643 
644  public function isMarked(): bool
645  {
646  return !is_null($this->marker);
647  }
648  };
649  }
650 
654  public function getPathMock(array $steps, bool $is_relative, bool $leads_to_one): PathInterface
655  {
656  return new class ($steps, $is_relative, $leads_to_one) extends NullPath {
660  public function __construct(
661  protected array $my_steps,
662  protected bool $is_relative,
663  protected bool $leads_to_one
664  ) {
665  }
666 
667  public function leadsToExactlyOneElement(): bool
668  {
669  return $this->leads_to_one;
670  }
671 
672  public function isRelative(): bool
673  {
674  return $this->is_relative;
675  }
676 
677  public function steps(): \Generator
678  {
679  yield from $this->my_steps;
680  }
681  };
682  }
683 
687  protected function getStepMock(string|StepToken $step_name, array $filter): StepInterface
688  {
689  return new class ($step_name, $filter) extends NullStep {
690  public function __construct(protected string|StepToken $step_name, protected array $my_filter)
691  {
692  }
693 
694  public function name(): string|StepToken
695  {
696  return $this->step_name;
697  }
698 
699  public function filters(): \Generator
700  {
701  yield from $this->my_filter;
702  }
703  };
704  }
705 
706  protected function getFilterMock(FilterType $filter_type, array $values): FilterInterface
707  {
708  return new class ($filter_type, $values) extends NullFilter {
709  public function __construct(protected FilterType $filter_type, protected array $my_values)
710  {
711  }
712 
713  public function type(): FilterType
714  {
715  return $this->filter_type;
716  }
717 
718  public function values(): \Generator
719  {
720  yield from $this->my_values;
721  }
722  };
723  }
724 
725  protected function createExpectedValuesArray(
726  int $expected_child_count,
727  int|NoID $expected_id,
728  string $expected_element_data_value,
729  Type $expected_data_type = Type::NULL,
730  ?Action $expected_marker_action = null,
731  string $exptected_marker_value = '',
732  array $expected_child_values = [],
733  ): array {
734  return [
735  'expected_child_count' => $expected_child_count,
736  'expected_id' => $expected_id,
737  'expected_element_data_value' => $expected_element_data_value,
738  'expected_data_type' => $expected_data_type,
739  'expected_marker_action' => $expected_marker_action,
740  'expected_marker_value' => $exptected_marker_value,
741  'children' => $expected_child_values
742  ];
743  }
744 
745  protected function myAssertElement(
746  ElementInterface $element_to_check,
747  array $expected_values
748  ): void {
757  $expected_child_count = $expected_values['expected_child_count'];
758  $expected_id = $expected_values['expected_id'];
759  $expected_element_data_value = $expected_values['expected_element_data_value'];
760  $expected_data_type = $expected_values['expected_data_type'];
761  $expected_marker_action = $expected_values['expected_marker_action'];
762  $expected_marker_value = $expected_values['expected_marker_value'];
763  $msg = 'Failed during check of element with data value: ' . $element_to_check->getData()->value()
764  . ', and with NoID: ' . ($element_to_check->getMDID() instanceof NoID ? $element_to_check->getMDID()->value : $element_to_check->getMDID());
765  if (is_null($expected_marker_action)) {
766  $this->assertSame(null, $element_to_check->getMarker(), $msg);
767  }
768  if (!is_null($expected_marker_action)) {
769  $this->assertNotSame(null, $element_to_check->getMarker(), $msg);
770  $this->assertSame($expected_marker_action, $element_to_check->getMarker()->action(), $msg);
771  $this->assertSame($expected_marker_value, $element_to_check->getMarker()->dataValue(), $msg);
772  }
773  $this->assertSame($expected_child_count, count(iterator_to_array($element_to_check->getSubElements())), $msg);
774  $this->assertSame($expected_id, $element_to_check->getMDID(), $msg);
775  $this->assertSame($expected_element_data_value, $element_to_check->getData()->value(), $msg);
776  $this->assertSame($expected_data_type, $element_to_check->getData()->type(), $msg);
777  }
778 
779  protected function myAssertTree(ElementInterface $root, array $expected_root_values)
780  {
785  $elements = [$root];
786  $expected_values = [$expected_root_values];
787  while (count($elements) > 0) {
788  $this->assertSame(count($elements), count($expected_values), 'Bad test value initializion');
789  $current_element = array_pop($elements);
790  $current_expected_values = array_pop($expected_values);
791  $this->myAssertElement($current_element, $current_expected_values);
792  array_push($elements, ...$current_element->getSubElements());
793  array_push($expected_values, ...$current_expected_values['children']);
794  }
795  }
796 
797  public function testPrepareDelete_001(): void
798  {
799  $manipulator = new Manipulator(
800  new NullScaffoldProvider(),
801  $this->getMarkerFactoryMock(),
802  $this->getNavigatorFactoryMock(),
803  $this->getPathFactoryMock(),
805  );
806 
807  $element_root = $this->getElementMock(NoID::ROOT, 'root', Type::NULL);
808  $element_general = $this->getElementMock(0, 'general', Type::NULL);
809  $element_subsection_1_0 = $this->getElementMock(1, 'subsection_1', Type::NULL);
810  $element_subsection_1_1 = $this->getElementMock(2, 'subsection_1', Type::NULL);
811  $element_target_0 = $this->getElementMock(3, 'target', Type::STRING);
812  $element_target_1 = $this->getElementMock(4, 'target', Type::STRING);
813  $element_target_2 = $this->getElementMock(5, 'target', Type::STRING);
814 
815  $element_root->addChildren($element_general);
816  $element_general->addChildren($element_subsection_1_0, $element_subsection_1_1);
817  $element_subsection_1_0->addChildren($element_target_0);
818  $element_subsection_1_1->addChildren($element_target_1, $element_target_2);
819 
820  $set = $this->getSetMock($element_root);
821  $delete_path = $this->getPathMock(
822  [
823  $this->getStepMock('general', [
824  $this->getFilterMock(FilterType::DATA, ['general'])
825  ]),
826  $this->getStepMock('subsection_1', [
827  $this->getFilterMock(FilterType::DATA, ['subsection_1']),
828  $this->getFilterMock(FilterType::MDID, [2])
829  ]),
830  $this->getStepMock('target', [
831  $this->getFilterMock(FilterType::DATA, ['target'])
832  ])
833  ],
834  false,
835  false
836  );
837 
838  try {
839  $manipulator->prepareDelete($set, $delete_path);
840  } catch (\ilMDPathException $e) {
841  $this->fail($e->getMessage());
842  }
843 
844  $expected_element_target_2 = $this->createExpectedValuesArray(
845  0,
846  5,
847  'target',
848  Type::STRING,
850  );
851 
852  $expected_element_target_1 = $this->createExpectedValuesArray(
853  0,
854  4,
855  'target',
856  Type::STRING,
858  );
859 
860  $expected_element_target_0 = $this->createExpectedValuesArray(
861  0,
862  3,
863  'target',
864  Type::STRING
865  );
866 
867  $expected_element_subsection_1_1 = $this->createExpectedValuesArray(
868  2,
869  2,
870  'subsection_1',
871  Type::NULL,
872  Action::NEUTRAL,
873  '',
874  [
875  $expected_element_target_1,
876  $expected_element_target_2
877  ]
878  );
879 
880  $expected_element_subsection_1_0 = $this->createExpectedValuesArray(
881  1,
882  1,
883  'subsection_1',
884  Type::NULL,
885  null,
886  '',
887  [
888  $expected_element_target_0
889  ]
890  );
891 
892  $expected_element_general = $this->createExpectedValuesArray(
893  2,
894  0,
895  'general',
896  Type::NULL,
897  Action::NEUTRAL,
898  '',
899  [
900  $expected_element_subsection_1_0,
901  $expected_element_subsection_1_1
902  ]
903  );
904 
905  $expected_element_root = $this->createExpectedValuesArray(
906  1,
907  NoID::ROOT,
908  'root',
909  Type::NULL,
910  Action::NEUTRAL,
911  '',
912  [
913  $expected_element_general
914  ]
915  );
916 
917  $this->myAssertTree($element_root, $expected_element_root);
918  }
919 
920  public function testPrepareDelete_002(): void
921  {
922  $manipulator = new Manipulator(
923  new NullScaffoldProvider(),
924  $this->getMarkerFactoryMock(),
925  $this->getNavigatorFactoryMock(),
926  $this->getPathFactoryMock(),
928  );
929 
930  $element_root = $this->getElementMock(NoID::ROOT, 'root', Type::NULL);
931  $element_general = $this->getElementMock(0, 'general', Type::NULL);
932  $element_subsection_1_0 = $this->getElementMock(1, 'subsection_1', Type::NULL);
933  $element_subsection_1_1 = $this->getElementMock(2, 'subsection_1', Type::NULL);
934  $element_target = $this->getElementMock(3, 'target', Type::STRING);
935 
936  $element_root->addChildren($element_general);
937  $element_general->addChildren($element_subsection_1_0, $element_subsection_1_1);
938  $element_subsection_1_0->addChildren($element_target);
939 
940  $set = $this->getSetMock($element_root);
941  $delete_path = $this->getPathMock(
942  [
943  $this->getStepMock('general', [
944  $this->getFilterMock(FilterType::DATA, ['general'])
945  ]),
946  $this->getStepMock('subsection_1', [
947  $this->getFilterMock(FilterType::DATA, ['subsection_1'])
948  ]),
949  $this->getStepMock('i_do_not_exist_one', [
950  $this->getFilterMock(FilterType::DATA, ['i_do_not_exist_one'])
951  ]),
952  $this->getStepMock('i_do_not_exist_two', [
953  $this->getFilterMock(FilterType::DATA, ['i_do_not_exist_two'])
954  ])
955  ],
956  false,
957  false
958  );
959 
960  try {
961  $manipulator->prepareDelete($set, $delete_path);
962  } catch (\ilMDPathException $e) {
963  $this->fail($e->getMessage());
964  }
965 
966  $expected_element_target = $this->createExpectedValuesArray(
967  0,
968  3,
969  'target',
970  Type::STRING
971  );
972 
973  $expected_element_subsection_1_1 = $this->createExpectedValuesArray(
974  0,
975  2,
976  'subsection_1'
977  );
978 
979  $expected_element_subsection_1_0 = $this->createExpectedValuesArray(
980  1,
981  1,
982  'subsection_1',
983  Type::NULL,
984  null,
985  '',
986  [
987  $expected_element_target
988  ]
989  );
990 
991  $expected_element_general = $this->createExpectedValuesArray(
992  2,
993  0,
994  'general',
995  Type::NULL,
996  null,
997  '',
998  [
999  $expected_element_subsection_1_0,
1000  $expected_element_subsection_1_1
1001  ]
1002  );
1003 
1004  $expected_element_root = $this->createExpectedValuesArray(
1005  1,
1006  NoID::ROOT,
1007  'root',
1008  Type::NULL,
1009  null,
1010  '',
1011  [
1012  $expected_element_general
1013  ]
1014  );
1015 
1016  $this->myAssertTree($element_root, $expected_element_root);
1017  }
1018 
1019  public function testPrepareCreateOrUpdate_001(): void
1020  {
1021  $manipulator = new Manipulator(
1022  $this->getScaffoldProviderMock(),
1023  $this->getMarkerFactoryMock(),
1024  $this->getNavigatorFactoryMock(),
1025  $this->getPathFactoryMock(),
1027  );
1028 
1029  $path = $this->getPathMock([
1030  $this->getStepMock('general', [
1031  $this->getFilterMock(FilterType::NULL, [])
1032  ])
1033  ], false, false);
1034 
1035  $element_root = $this->getElementMock(NoID::ROOT, 'root', Type::NULL, true);
1036 
1037  try {
1038  $manipulator->prepareCreateOrUpdate($this->getSetMock($element_root), $path, 'test');
1039  } catch (\ilMDPathException $e) {
1040  $this->fail($e->getMessage());
1041  }
1042 
1043  $expected_element_general = $this->createExpectedValuesArray(
1044  0,
1045  NoID::SCAFFOLD,
1046  'general',
1047  Type::NULL,
1048  Action::CREATE_OR_UPDATE,
1049  'test',
1050  );
1051 
1052  $expected_element_root = $this->createExpectedValuesArray(
1053  1,
1054  NoID::ROOT,
1055  'root',
1056  Type::NULL,
1057  Action::NEUTRAL,
1058  '',
1059  [
1060  $expected_element_general
1061  ]
1062  );
1063 
1064  $this->myAssertTree($element_root, $expected_element_root);
1065  }
1066 
1067  public function testPrepareCreateOrUpdate_002(): void
1068  {
1069  $manipulator = new Manipulator(
1070  $this->getScaffoldProviderMock(),
1071  $this->getMarkerFactoryMock(),
1072  $this->getNavigatorFactoryMock(),
1073  $this->getPathFactoryMock(),
1075  );
1076 
1077  $add_path = $this->getPathMock([
1078  $this->getStepMock('general', [
1079  $this->getFilterMock(FilterType::DATA, ['general'])
1080  ]),
1081  $this->getStepMock('tags', [
1082  $this->getFilterMock(FilterType::DATA, ['tags'])
1083  ]),
1084  $this->getStepMock('tag', [
1085  $this->getFilterMock(FilterType::DATA, ['tag']),
1086  $this->getFilterMock(FilterType::INDEX, [0, 1])
1087  ]),
1088  ], false, false);
1089 
1090  $element_root = $this->getElementMock(NoID::ROOT, 'root', Type::NULL, true);
1091  $element_general = $this->getElementMock(0, 'general', Type::NULL, true);
1092  $element_special = $this->getElementMock(1, 'special', Type::NULL, true);
1093 
1094  $element_root->addChildren($element_general, $element_special);
1095 
1096  try {
1097  $manipulator->prepareCreateOrUpdate($this->getSetMock($element_root), $add_path, 'test1', 'test2');
1098  } catch (\ilMDPathException $e) {
1099  $this->fail($e->getMessage());
1100  }
1101 
1102  $expected_element_tag_1 = $this->createExpectedValuesArray(
1103  0,
1104  NoID::SCAFFOLD,
1105  'tag',
1106  Type::NULL,
1107  Action::CREATE_OR_UPDATE,
1108  'test2',
1109  );
1110 
1111  $expected_element_tag_0 = $this->createExpectedValuesArray(
1112  0,
1113  NoID::SCAFFOLD,
1114  'tag',
1115  Type::NULL,
1116  Action::CREATE_OR_UPDATE,
1117  'test1',
1118  );
1119 
1120  $expected_element_tags = $this->createExpectedValuesArray(
1121  2,
1122  NoID::SCAFFOLD,
1123  'tags',
1124  Type::NULL,
1125  Action::CREATE_OR_UPDATE,
1126  'tags',
1127  [
1128  $expected_element_tag_0,
1129  $expected_element_tag_1
1130  ]
1131  );
1132 
1133  $expected_element_special = $this->createExpectedValuesArray(
1134  0,
1135  1,
1136  'special',
1137  );
1138 
1139  $expected_element_general = $this->createExpectedValuesArray(
1140  1,
1141  0,
1142  'general',
1143  Type::NULL,
1144  Action::NEUTRAL,
1145  '',
1146  [
1147  $expected_element_tags
1148  ]
1149  );
1150 
1151  $expected_element_root = $this->createExpectedValuesArray(
1152  2,
1153  NoID::ROOT,
1154  'root',
1155  Type::NULL,
1156  Action::NEUTRAL,
1157  '',
1158  [
1159  $expected_element_general,
1160  $expected_element_special
1161  ]
1162  );
1163 
1164  $this->myAssertTree($element_root, $expected_element_root);
1165  }
1166 
1167  public function testPrepareCreateOrUpdate_003(): void
1168  {
1169  $manipulator = new Manipulator(
1170  $this->getScaffoldProviderMock(),
1171  $this->getMarkerFactoryMock(),
1172  $this->getNavigatorFactoryMock(),
1173  $this->getPathFactoryMock(),
1175  );
1176 
1177  $add_path = $this->getPathMock([
1178  $this->getStepMock('general', [
1179  $this->getFilterMock(FilterType::DATA, ['general'])
1180  ]),
1181  $this->getStepMock('tags', [
1182  $this->getFilterMock(FilterType::DATA, ['tags'])
1183  ]),
1184  $this->getStepMock('tag', [
1185  $this->getFilterMock(FilterType::DATA, ['tag']),
1186  $this->getFilterMock(FilterType::INDEX, [0, 2])
1187  ]),
1188  ], false, false);
1189 
1190  $element_root = $this->getElementMock(NoID::ROOT, 'root', Type::NULL, true);
1191  $element_general = $this->getElementMock(0, 'general', Type::NULL, true);
1192  $element_special = $this->getElementMock(1, 'special', Type::NULL, true);
1193  $element_tags = $this->getElementMock(2, 'tags', Type::NULL, true);
1194  $element_tag_0 = $this->getElementMock(3, 'tag', Type::STRING);
1195  $element_tag_1 = $this->getElementMock(4, 'tag', Type::STRING);
1196  $element_tag_2 = $this->getElementMock(5, 'tag', Type::STRING);
1197  $element_tag_3 = $this->getElementMock(6, 'tag', Type::STRING);
1198 
1199  $element_root->addChildren($element_general, $element_special);
1200  $element_general->addChildren($element_tags);
1201  $element_tags->addChildren($element_tag_0, $element_tag_1, $element_tag_2, $element_tag_3);
1202 
1203  try {
1204  $manipulator->prepareCreateOrUpdate($this->getSetMock($element_root), $add_path, 'test1', 'test2');
1205  } catch (\ilMDPathException $e) {
1206  $this->fail($e->getMessage());
1207  }
1208 
1209  $expected_element_tag_3 = $this->createExpectedValuesArray(
1210  0,
1211  6,
1212  'tag',
1213  Type::STRING
1214  );
1215 
1216  $expected_element_tag_2 = $this->createExpectedValuesArray(
1217  0,
1218  5,
1219  'tag',
1220  Type::STRING,
1221  Action::CREATE_OR_UPDATE,
1222  'test2'
1223  );
1224 
1225  $expected_element_tag_1 = $this->createExpectedValuesArray(
1226  0,
1227  4,
1228  'tag',
1229  Type::STRING
1230  );
1231 
1232  $expected_element_tag_0 = $this->createExpectedValuesArray(
1233  0,
1234  3,
1235  'tag',
1236  Type::STRING,
1237  Action::CREATE_OR_UPDATE,
1238  'test1'
1239  );
1240 
1241  $expected_element_tags = $this->createExpectedValuesArray(
1242  4,
1243  2,
1244  'tags',
1245  Type::NULL,
1246  Action::NEUTRAL,
1247  '',
1248  [
1249  $expected_element_tag_0,
1250  $expected_element_tag_1,
1251  $expected_element_tag_2,
1252  $expected_element_tag_3
1253  ]
1254  );
1255 
1256  $expected_element_special = $this->createExpectedValuesArray(
1257  0,
1258  1,
1259  'special'
1260  );
1261 
1262  $expected_element_general = $this->createExpectedValuesArray(
1263  1,
1264  0,
1265  'general',
1266  Type::NULL,
1267  Action::NEUTRAL,
1268  '',
1269  [
1270  $expected_element_tags
1271  ]
1272  );
1273 
1274  $expected_element_root = $this->createExpectedValuesArray(
1275  2,
1276  NoID::ROOT,
1277  'root',
1278  Type::NULL,
1279  Action::NEUTRAL,
1280  '',
1281  [
1282  $expected_element_general,
1283  $expected_element_special
1284  ]
1285  );
1286 
1287  $this->myAssertTree($element_root, $expected_element_root);
1288  }
1289 
1290  public function testPrepareCreateOrUpdate_004(): void
1291  {
1292  $manipulator = new Manipulator(
1293  $this->getScaffoldProviderMock(),
1294  $this->getMarkerFactoryMock(),
1295  $this->getNavigatorFactoryMock(),
1296  $this->getPathFactoryMock(),
1298  );
1299 
1300  $add_path = $this->getPathMock([
1301  $this->getStepMock('general', [
1302  $this->getFilterMock(FilterType::DATA, ['general'])
1303  ]),
1304  $this->getStepMock('general_condition', [
1305  $this->getFilterMock(FilterType::DATA, ['general_condition'])
1306  ]),
1307  $this->getStepMock(StepToken::SUPER, []),
1308  $this->getStepMock('tags', [
1309  $this->getFilterMock(FilterType::DATA, ['tags'])
1310  ]),
1311  $this->getStepMock('tag', [
1312  $this->getFilterMock(FilterType::DATA, ['tag']),
1313  $this->getFilterMock(FilterType::INDEX, [0, 2])
1314  ]),
1315  ], false, false);
1316 
1317  $element_root = $this->getElementMock(NoID::ROOT, 'root', Type::NULL, true);
1318  $element_general = $this->getElementMock(0, 'general', Type::NULL, true);
1319  $element_special = $this->getElementMock(1, 'special', Type::NULL, true);
1320  $element_general_condition = $this->getElementMock(2, 'general_condition', Type::NULL);
1321  $element_tags = $this->getElementMock(3, 'tags', Type::NULL, true);
1322  $element_tag_0 = $this->getElementMock(4, 'tag', Type::STRING);
1323  $element_tag_1 = $this->getElementMock(5, 'tag', Type::STRING);
1324  $element_tag_2 = $this->getElementMock(6, 'tag', Type::STRING);
1325  $element_tag_3 = $this->getElementMock(7, 'tag', Type::STRING);
1326 
1327  $element_root->addChildren($element_general, $element_special);
1328  $element_general->addChildren($element_general_condition, $element_tags);
1329  $element_tags->addChildren($element_tag_0, $element_tag_1, $element_tag_2, $element_tag_3);
1330 
1331  try {
1332  $manipulator->prepareCreateOrUpdate($this->getSetMock($element_root), $add_path, 'test1', 'test2');
1333  } catch (\ilMDPathException $e) {
1334  $this->fail($e->getMessage());
1335  }
1336 
1337  $expected_element_tag_3 = $this->createExpectedValuesArray(
1338  0,
1339  7,
1340  'tag',
1341  Type::STRING
1342  );
1343 
1344  $expected_element_tag_2 = $this->createExpectedValuesArray(
1345  0,
1346  6,
1347  'tag',
1348  Type::STRING,
1349  Action::CREATE_OR_UPDATE,
1350  'test2'
1351  );
1352 
1353  $expected_element_tag_1 = $this->createExpectedValuesArray(
1354  0,
1355  5,
1356  'tag',
1357  Type::STRING
1358  );
1359 
1360  $expected_element_tag_0 = $this->createExpectedValuesArray(
1361  0,
1362  4,
1363  'tag',
1364  Type::STRING,
1365  Action::CREATE_OR_UPDATE,
1366  'test1'
1367  );
1368 
1369  $expected_element_tags = $this->createExpectedValuesArray(
1370  4,
1371  3,
1372  'tags',
1373  Type::NULL,
1374  Action::NEUTRAL,
1375  '',
1376  [
1377  $expected_element_tag_0,
1378  $expected_element_tag_1,
1379  $expected_element_tag_2,
1380  $expected_element_tag_3
1381  ]
1382  );
1383 
1384  $expected_element_general_condition = $this->createExpectedValuesArray(
1385  0,
1386  2,
1387  'general_condition'
1388  );
1389 
1390  $expected_element_special = $this->createExpectedValuesArray(
1391  0,
1392  1,
1393  'special'
1394  );
1395 
1396  $expected_element_general = $this->createExpectedValuesArray(
1397  2,
1398  0,
1399  'general',
1400  Type::NULL,
1401  Action::NEUTRAL,
1402  '',
1403  [
1404  $expected_element_general_condition,
1405  $expected_element_tags
1406  ]
1407  );
1408 
1409  $expected_element_root = $this->createExpectedValuesArray(
1410  2,
1411  NoID::ROOT,
1412  'root',
1413  Type::NULL,
1414  Action::NEUTRAL,
1415  '',
1416  [
1417  $expected_element_general,
1418  $expected_element_special
1419  ]
1420  );
1421 
1422  $this->myAssertTree($element_root, $expected_element_root);
1423  }
1424 
1425  public function testPrepareCreateOrUpdate_005(): void
1426  {
1427  $manipulator = new Manipulator(
1428  $this->getScaffoldProviderMock(),
1429  $this->getMarkerFactoryMock(),
1430  $this->getNavigatorFactoryMock(),
1431  $this->getPathFactoryMock(),
1433  );
1434 
1435  $add_path = $this->getPathMock([
1436  $this->getStepMock('general', [
1437  $this->getFilterMock(FilterType::DATA, ['general'])
1438  ]),
1439  $this->getStepMock('tags', [
1440  $this->getFilterMock(FilterType::DATA, ['tags'])
1441  ]),
1442  $this->getStepMock('tags_condition', [
1443  $this->getFilterMock(FilterType::DATA, ['tags_condition'])
1444  ]),
1445  $this->getStepMock(StepToken::SUPER, []),
1446  $this->getStepMock('tag', [
1447  $this->getFilterMock(FilterType::DATA, ['tag'])
1448  ]),
1449  ], false, false);
1450 
1451  $element_root = $this->getElementMock(NoID::ROOT, 'root', Type::NULL, true);
1452  $element_general = $this->getElementMock(0, 'general', Type::NULL, true);
1453  $element_special = $this->getElementMock(1, 'special', Type::NULL, true);
1454  $element_general_condition = $this->getElementMock(2, 'general_condition', Type::NULL);
1455  $element_tags = $this->getElementMock(3, 'tags', Type::NULL, true);
1456  $element_tag_0 = $this->getElementMock(4, 'tag', Type::STRING);
1457 
1458  $element_root->addChildren($element_general, $element_special);
1459  $element_general->addChildren($element_general_condition, $element_tags);
1460  $element_tags->addChildren($element_tag_0);
1461 
1462  try {
1463  $manipulator->prepareCreateOrUpdate(
1464  $this->getSetMock($element_root),
1465  $add_path,
1466  'test1',
1467  'test2',
1468  'test3'
1469  );
1470  } catch (\ilMDPathException $e) {
1471  $this->fail($e->getMessage());
1472  }
1473 
1474  $expected_element_tag_3 = $this->createExpectedValuesArray(
1475  0,
1476  NoID::SCAFFOLD,
1477  'tag',
1478  Type::NULL,
1479  Action::CREATE_OR_UPDATE,
1480  'test3'
1481  );
1482 
1483  $expected_element_tag_2 = $this->createExpectedValuesArray(
1484  0,
1485  NoID::SCAFFOLD,
1486  'tag',
1487  Type::NULL,
1488  Action::CREATE_OR_UPDATE,
1489  'test2'
1490  );
1491 
1492  $expected_element_tag_1 = $this->createExpectedValuesArray(
1493  0,
1494  NoID::SCAFFOLD,
1495  'tag',
1496  Type::NULL,
1497  Action::CREATE_OR_UPDATE,
1498  'test1'
1499  );
1500 
1501  $expected_element_tag_0 = $this->createExpectedValuesArray(
1502  0,
1503  4,
1504  'tag',
1505  Type::STRING
1506  );
1507 
1508  $expected_element_tags_condition = $this->createExpectedValuesArray(
1509  0,
1510  NoID::SCAFFOLD,
1511  'tags_condition',
1512  Type::NULL,
1513  Action::CREATE_OR_UPDATE,
1514  'tags_condition'
1515  );
1516 
1517  $expected_element_tags_created = $this->createExpectedValuesArray(
1518  4,
1519  NoID::SCAFFOLD,
1520  'tags',
1521  Type::NULL,
1522  Action::CREATE_OR_UPDATE,
1523  'tags',
1524  [
1525  $expected_element_tags_condition,
1526  $expected_element_tag_1,
1527  $expected_element_tag_2,
1528  $expected_element_tag_3
1529  ]
1530  );
1531 
1532  $expected_element_tags = $this->createExpectedValuesArray(
1533  1,
1534  3,
1535  'tags',
1536  Type::NULL,
1537  null,
1538  '',
1539  [
1540  $expected_element_tag_0
1541  ]
1542  );
1543 
1544  $expected_element_general_condition = $this->createExpectedValuesArray(
1545  0,
1546  2,
1547  'general_condition'
1548  );
1549 
1550  $expected_element_special = $this->createExpectedValuesArray(
1551  0,
1552  1,
1553  'special'
1554  );
1555 
1556  $expected_element_general = $this->createExpectedValuesArray(
1557  3,
1558  0,
1559  'general',
1560  Type::NULL,
1561  Action::NEUTRAL,
1562  '',
1563  [
1564  $expected_element_general_condition,
1565  $expected_element_tags,
1566  $expected_element_tags_created
1567  ]
1568  );
1569 
1570  $expected_element_root = $this->createExpectedValuesArray(
1571  2,
1572  NoID::ROOT,
1573  'root',
1574  Type::NULL,
1575  Action::NEUTRAL,
1576  '',
1577  [
1578  $expected_element_general,
1579  $expected_element_special
1580  ]
1581  );
1582 
1583  $this->myAssertTree($element_root, $expected_element_root);
1584  }
1585 
1586  public function testPrepareForceCreate01(): void
1587  {
1588  $manipulator = new Manipulator(
1589  $this->getScaffoldProviderMock(),
1590  $this->getMarkerFactoryMock(),
1591  $this->getNavigatorFactoryMock(),
1592  $this->getPathFactoryMock(),
1594  );
1595 
1596  $add_path = $this->getPathMock([
1597  $this->getStepMock('general', [
1598  $this->getFilterMock(FilterType::DATA, ['general'])
1599  ]),
1600  $this->getStepMock('tags', [
1601  $this->getFilterMock(FilterType::DATA, ['tags'])
1602  ]),
1603  $this->getStepMock('tags_condition', [
1604  $this->getFilterMock(FilterType::DATA, ['tags_condition'])
1605  ]),
1606  $this->getStepMock(StepToken::SUPER, []),
1607  $this->getStepMock('tag', [
1608  $this->getFilterMock(FilterType::DATA, ['tag'])
1609  ]),
1610  ], false, false);
1611 
1612  $element_root = $this->getElementMock(NoID::ROOT, 'root', Type::NULL, true);
1613  $element_general = $this->getElementMock(0, 'general', Type::NULL, true);
1614  $element_special = $this->getElementMock(1, 'special', Type::NULL, true);
1615  $element_general_condition = $this->getElementMock(2, 'general_condition', Type::NULL);
1616  $element_tags = $this->getElementMock(3, 'tags', Type::NULL, true);
1617  $element_tag_0 = $this->getElementMock(4, 'tag', Type::STRING);
1618  $element_tags_condition = $this->getElementMock(5, 'tags_condition', Type::NULL, true);
1619 
1620  $element_root->addChildren($element_general, $element_special);
1621  $element_general->addChildren($element_general_condition, $element_tags);
1622  $element_tags->addChildren($element_tag_0, $element_tags_condition);
1623 
1624  try {
1625  $manipulator->prepareForceCreate(
1626  $this->getSetMock($element_root),
1627  $add_path,
1628  'test1',
1629  'test2',
1630  'test3'
1631  );
1632  } catch (\ilMDPathException $e) {
1633  $this->fail($e->getMessage());
1634  }
1635 
1636  $expected_element_tag_3 = $this->createExpectedValuesArray(
1637  0,
1638  NoID::SCAFFOLD,
1639  'tag',
1640  Type::NULL,
1641  Action::CREATE_OR_UPDATE,
1642  'test3'
1643  );
1644 
1645  $expected_element_tag_2 = $this->createExpectedValuesArray(
1646  0,
1647  NoID::SCAFFOLD,
1648  'tag',
1649  Type::NULL,
1650  Action::CREATE_OR_UPDATE,
1651  'test2'
1652  );
1653 
1654  $expected_element_tag_1 = $this->createExpectedValuesArray(
1655  0,
1656  NoID::SCAFFOLD,
1657  'tag',
1658  Type::NULL,
1659  Action::CREATE_OR_UPDATE,
1660  'test1'
1661  );
1662 
1663  $expected_element_tag_0 = $this->createExpectedValuesArray(
1664  0,
1665  4,
1666  'tag',
1667  Type::STRING
1668  );
1669 
1670  $expected_element_tags_condition = $this->createExpectedValuesArray(
1671  0,
1672  5,
1673  'tags_condition',
1674  Type::NULL
1675  );
1676 
1677  $expected_element_tags = $this->createExpectedValuesArray(
1678  5,
1679  3,
1680  'tags',
1681  Type::NULL,
1682  Action::NEUTRAL,
1683  '',
1684  [
1685  $expected_element_tag_0,
1686  $expected_element_tags_condition,
1687  $expected_element_tag_1,
1688  $expected_element_tag_2,
1689  $expected_element_tag_3
1690  ]
1691  );
1692 
1693  $expected_element_general_condition = $this->createExpectedValuesArray(
1694  0,
1695  2,
1696  'general_condition'
1697  );
1698 
1699  $expected_element_special = $this->createExpectedValuesArray(
1700  0,
1701  1,
1702  'special'
1703  );
1704 
1705  $expected_element_general = $this->createExpectedValuesArray(
1706  2,
1707  0,
1708  'general',
1709  Type::NULL,
1710  Action::NEUTRAL,
1711  '',
1712  [
1713  $expected_element_general_condition,
1714  $expected_element_tags
1715  ]
1716  );
1717 
1718  $expected_element_root = $this->createExpectedValuesArray(
1719  2,
1720  NoID::ROOT,
1721  'root',
1722  Type::NULL,
1723  Action::NEUTRAL,
1724  '',
1725  [
1726  $expected_element_general,
1727  $expected_element_special
1728  ]
1729  );
1730 
1731  $this->myAssertTree($element_root, $expected_element_root);
1732  }
1733 
1734  public function testPrepareForceCreate02(): void
1735  {
1736  $manipulator = new Manipulator(
1737  $this->getScaffoldProviderMock(),
1738  $this->getMarkerFactoryMock(),
1739  $this->getNavigatorFactoryMock(),
1740  $this->getPathFactoryMock(),
1742  );
1743 
1744  $add_path = $this->getPathMock([
1745  $this->getStepMock('general', [
1746  $this->getFilterMock(FilterType::DATA, ['general'])
1747  ]),
1748  $this->getStepMock('tags', [
1749  $this->getFilterMock(FilterType::DATA, ['tags'])
1750  ]),
1751  $this->getStepMock('tag', [
1752  $this->getFilterMock(FilterType::DATA, ['tag'])
1753  ]),
1754  ], false, false);
1755 
1756  $element_root = $this->getElementMock(NoID::ROOT, 'root', Type::NULL, true);
1757  $element_general = $this->getElementMock(0, 'general', Type::NULL, true);
1758  $element_tags = $this->getElementMock(1, 'tags', Type::NULL, true);
1759  $element_tag_0 = $this->getElementMock(2, 'tag', Type::STRING);
1760 
1761  $element_root->addChildren($element_general);
1762  $element_general->addChildren($element_tags);
1763  $element_tags->addChildren($element_tag_0);
1764 
1765  try {
1766  $manipulator->prepareForceCreate(
1767  $this->getSetMock($element_root),
1768  $add_path,
1769  'test1',
1770  'test2',
1771  'test3'
1772  );
1773  } catch (\ilMDPathException $e) {
1774  $this->fail($e->getMessage());
1775  }
1776 
1777  $expected_element_tag_3 = $this->createExpectedValuesArray(
1778  0,
1779  NoID::SCAFFOLD,
1780  'tag',
1781  Type::NULL,
1782  Action::CREATE_OR_UPDATE,
1783  'test3'
1784  );
1785 
1786  $expected_element_tag_2 = $this->createExpectedValuesArray(
1787  0,
1788  NoID::SCAFFOLD,
1789  'tag',
1790  Type::NULL,
1791  Action::CREATE_OR_UPDATE,
1792  'test2'
1793  );
1794 
1795  $expected_element_tag_1 = $this->createExpectedValuesArray(
1796  0,
1797  NoID::SCAFFOLD,
1798  'tag',
1799  Type::NULL,
1800  Action::CREATE_OR_UPDATE,
1801  'test1'
1802  );
1803 
1804  $expected_element_tag_0 = $this->createExpectedValuesArray(
1805  0,
1806  2,
1807  'tag',
1808  Type::STRING
1809  );
1810 
1811  $expected_element_tags = $this->createExpectedValuesArray(
1812  4,
1813  1,
1814  'tags',
1815  Type::NULL,
1816  Action::NEUTRAL,
1817  '',
1818  [
1819  $expected_element_tag_0,
1820  $expected_element_tag_1,
1821  $expected_element_tag_2,
1822  $expected_element_tag_3
1823  ]
1824  );
1825 
1826  $expected_element_general = $this->createExpectedValuesArray(
1827  1,
1828  0,
1829  'general',
1830  Type::NULL,
1831  Action::NEUTRAL,
1832  '',
1833  [
1834  $expected_element_tags
1835  ]
1836  );
1837 
1838  $expected_element_root = $this->createExpectedValuesArray(
1839  1,
1840  NoID::ROOT,
1841  'root',
1842  Type::NULL,
1843  Action::NEUTRAL,
1844  '',
1845  [
1846  $expected_element_general
1847  ]
1848  );
1849 
1850  $this->myAssertTree($element_root, $expected_element_root);
1851  }
1852 }
steps()
Get all steps in the path.
FilterType
Values should always be all lowercase.
Definition: FilterType.php:26
getMarkerMock(Action $action, string $data_value='')
getSetMock(ElementInterface $set_root)
$path
Definition: ltiservices.php:29
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
marker(Action $action, string $data_value='')
__construct()
Constructor setup ILIAS global object public.
Definition: class.ilias.php:76
getPathMock(array $steps, bool $is_relative, bool $leads_to_one)
name()
Steps are identified by the names of LOM elements, or a token to specify a step to the super-element...
StepToken
The string representation of these tokens must not occur as names of metadata elements.
Definition: StepToken.php:27
getPathConditionCheckerMock(PathConditionsCollectionInterface $path_conditions_collection)
getDefinitionMock(string $name, Type $data_type, bool $is_unique)
getStepMock(string|StepToken $step_name, array $filter)
custom()
expected output: > ILIAS shows a base horizontal bar chart but customized with e.g.
Definition: custom.php:33
getFilterMock(FilterType $filter_type, array $values)
createExpectedValuesArray(int $expected_child_count, int|NoID $expected_id, string $expected_element_data_value, Type $expected_data_type=Type::NULL, ?Action $expected_marker_action=null, string $exptected_marker_value='', array $expected_child_values=[],)