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