ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\MetaData\Manipulator\ManipulatorTest Class Reference
+ Inheritance diagram for ILIAS\MetaData\Manipulator\ManipulatorTest:
+ Collaboration diagram for ILIAS\MetaData\Manipulator\ManipulatorTest:

Public Member Functions

 getMarkerMock (Action $action, string $data_value='')
 
 getPathConditionCheckerMock (PathConditionsCollectionInterface $path_conditions_collection)
 
 getPathFactoryMock ()
 
 getNavigatorFactoryMock ()
 
 getDataMock (string $value, Type $type)
 
 getDefinitionMock (string $name, Type $data_type, bool $is_unique)
 
 getPathMock (array $steps, bool $is_relative, bool $leads_to_one)
 
 testPrepareDelete_001 ()
 
 testPrepareDelete_002 ()
 
 testPrepareCreateOrUpdate_001 ()
 
 testPrepareCreateOrUpdate_002 ()
 
 testPrepareCreateOrUpdate_003 ()
 
 testPrepareCreateOrUpdate_004 ()
 
 testPrepareCreateOrUpdate_005 ()
 
 testPrepareForceCreate01 ()
 
 testPrepareForceCreate02 ()
 

Protected Member Functions

 getSetMock (ElementInterface $set_root)
 
 getScaffoldProviderMock ()
 
 getMarkerFactoryMock ()
 
 getPathUtilitiesFactoryMock ()
 
 getStepMock (string|StepToken $step_name, array $filter)
 
 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=[],)
 

Detailed Description

Definition at line 69 of file ManipulatorTest.php.

Member Function Documentation

◆ createExpectedValuesArray()

ILIAS\MetaData\Manipulator\ManipulatorTest::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 = [] 
)
protected

Definition at line 725 of file ManipulatorTest.php.

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 }

◆ getDataMock()

ILIAS\MetaData\Manipulator\ManipulatorTest::getDataMock ( string  $value,
Type  $type 
)

Definition at line 503 of file ManipulatorTest.php.

503 : 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 }
__construct()
Constructor setup ILIAS global object @access public.
Definition: class.ilias.php:76

References ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

◆ getDefinitionMock()

ILIAS\MetaData\Manipulator\ManipulatorTest::getDefinitionMock ( string  $name,
Type  $data_type,
bool  $is_unique 
)

Definition at line 522 of file ManipulatorTest.php.

526 : DefinitionInterface {
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 }

◆ getFilterMock()

ILIAS\MetaData\Manipulator\ManipulatorTest::getFilterMock ( FilterType  $filter_type,
array  $values 
)
protected

Definition at line 706 of file ManipulatorTest.php.

706 : 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 }
FilterType
Values should always be all lowercase.
Definition: FilterType.php:27

References ILIAS\GlobalScreen\Provider\__construct(), and ILIAS\ResourceStorage\Flavour\Machine\DefaultMachines\from().

+ Here is the call graph for this function:

◆ getMarkerFactoryMock()

ILIAS\MetaData\Manipulator\ManipulatorTest::getMarkerFactoryMock ( )
protected

Definition at line 119 of file ManipulatorTest.php.

119 : MarkerFactoryInterface
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 }

References ILIAS\__construct().

+ Here is the call graph for this function:

◆ getMarkerMock()

ILIAS\MetaData\Manipulator\ManipulatorTest::getMarkerMock ( Action  $action,
string  $data_value = '' 
)

Definition at line 100 of file ManipulatorTest.php.

100 : 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 }

References ILIAS\__construct().

+ Here is the call graph for this function:

◆ getNavigatorFactoryMock()

ILIAS\MetaData\Manipulator\ManipulatorTest::getNavigatorFactoryMock ( )

Definition at line 466 of file ManipulatorTest.php.

466 : NavigatorFactoryInterface
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 }
$path
Definition: ltiservices.php:30

References $path, and ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

◆ getPathConditionCheckerMock()

ILIAS\MetaData\Manipulator\ManipulatorTest::getPathConditionCheckerMock ( PathConditionsCollectionInterface  $path_conditions_collection)

Definition at line 347 of file ManipulatorTest.php.

349 : PathConditionsCheckerInterface {
350 return new class (
351 $path_conditions_collection,
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 }

◆ getPathFactoryMock()

ILIAS\MetaData\Manipulator\ManipulatorTest::getPathFactoryMock ( )

Definition at line 408 of file ManipulatorTest.php.

408 : PathFactoryInterface
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 }

References ILIAS\GlobalScreen\Provider\__construct(), and ILIAS\UI\examples\Chart\Bar\Horizontal\custom().

+ Here is the call graph for this function:

◆ getPathMock()

ILIAS\MetaData\Manipulator\ManipulatorTest::getPathMock ( array  $steps,
bool  $is_relative,
bool  $leads_to_one 
)
Parameters
StepInterface[]$steps
Parameters
StepInterface[]$my_steps

Definition at line 654 of file ManipulatorTest.php.

654 : 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 }

References ILIAS\GlobalScreen\Provider\__construct(), and ILIAS\ResourceStorage\Flavour\Machine\DefaultMachines\from().

+ Here is the call graph for this function:

◆ getPathUtilitiesFactoryMock()

ILIAS\MetaData\Manipulator\ManipulatorTest::getPathUtilitiesFactoryMock ( )
protected

Definition at line 480 of file ManipulatorTest.php.

480 : PathUtilitiesFactoryInterface
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
492 ): PathConditionsCheckerInterface {
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 }
getPathConditionCheckerMock(PathConditionsCollectionInterface $path_conditions_collection)
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References $path, and ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

◆ getScaffoldProviderMock()

ILIAS\MetaData\Manipulator\ManipulatorTest::getScaffoldProviderMock ( )
protected

Definition at line 90 of file ManipulatorTest.php.

90 : ScaffoldProviderInterface
91 {
92 return new class () extends NullScaffoldProvider {
93 public function getScaffoldsForElement(ElementInterface $element): \Generator
94 {
95 yield from [];
96 }
97 };
98 }

References ILIAS\ResourceStorage\Flavour\Machine\DefaultMachines\from().

+ Here is the call graph for this function:

◆ getSetMock()

ILIAS\MetaData\Manipulator\ManipulatorTest::getSetMock ( ElementInterface  $set_root)
protected

Definition at line 71 of file ManipulatorTest.php.

71 : 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 }

References ILIAS\__construct().

+ Here is the call graph for this function:

◆ getStepMock()

ILIAS\MetaData\Manipulator\ManipulatorTest::getStepMock ( string|StepToken  $step_name,
array  $filter 
)
protected
Parameters
FilterInterface[]$filter

Definition at line 687 of file ManipulatorTest.php.

687 : 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 }
StepToken
The string representation of these tokens must not occur as names of metadata elements.
Definition: StepToken.php:28

References ILIAS\GlobalScreen\Provider\__construct(), and ILIAS\ResourceStorage\Flavour\Machine\DefaultMachines\from().

+ Here is the call graph for this function:

◆ testPrepareCreateOrUpdate_001()

ILIAS\MetaData\Manipulator\ManipulatorTest::testPrepareCreateOrUpdate_001 ( )

Definition at line 1019 of file ManipulatorTest.php.

1019 : 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', [
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 }
getFilterMock(FilterType $filter_type, array $values)
getStepMock(string|StepToken $step_name, array $filter)
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=[],)
getPathMock(array $steps, bool $is_relative, bool $leads_to_one)
getSetMock(ElementInterface $set_root)

References Vendor\Package\$e, $path, and ILIAS\Data\Description\NULL.

◆ testPrepareCreateOrUpdate_002()

ILIAS\MetaData\Manipulator\ManipulatorTest::testPrepareCreateOrUpdate_002 ( )

Definition at line 1067 of file ManipulatorTest.php.

1067 : 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 }

References Vendor\Package\$e, ILIAS\MetaData\Paths\Filters\DATA, and ILIAS\Data\Description\NULL.

◆ testPrepareCreateOrUpdate_003()

ILIAS\MetaData\Manipulator\ManipulatorTest::testPrepareCreateOrUpdate_003 ( )

Definition at line 1167 of file ManipulatorTest.php.

1167 : 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 }

References Vendor\Package\$e, ILIAS\MetaData\Paths\Filters\DATA, and ILIAS\Data\Description\NULL.

◆ testPrepareCreateOrUpdate_004()

ILIAS\MetaData\Manipulator\ManipulatorTest::testPrepareCreateOrUpdate_004 ( )

Definition at line 1290 of file ManipulatorTest.php.

1290 : 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 }

References Vendor\Package\$e, ILIAS\MetaData\Paths\Filters\DATA, ILIAS\Data\Description\NULL, and ILIAS\MetaData\Paths\Steps\SUPER.

◆ testPrepareCreateOrUpdate_005()

ILIAS\MetaData\Manipulator\ManipulatorTest::testPrepareCreateOrUpdate_005 ( )

Definition at line 1425 of file ManipulatorTest.php.

1425 : 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 }

References Vendor\Package\$e, ILIAS\MetaData\Paths\Filters\DATA, ILIAS\Data\Description\NULL, and ILIAS\MetaData\Paths\Steps\SUPER.

◆ testPrepareDelete_001()

ILIAS\MetaData\Manipulator\ManipulatorTest::testPrepareDelete_001 ( )

Definition at line 797 of file ManipulatorTest.php.

797 : void
798 {
799 $manipulator = new Manipulator(
800 new NullScaffoldProvider(),
801 $this->getMarkerFactoryMock(),
803 $this->getPathFactoryMock(),
804 new NullPathUtilitiesFactory()
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',
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',
885 null,
886 '',
887 [
888 $expected_element_target_0
889 ]
890 );
891
892 $expected_element_general = $this->createExpectedValuesArray(
893 2,
894 0,
895 'general',
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',
910 Action::NEUTRAL,
911 '',
912 [
913 $expected_element_general
914 ]
915 );
916
917 $this->myAssertTree($element_root, $expected_element_root);
918 }

References Vendor\Package\$e, ILIAS\MetaData\Paths\Filters\DATA, ILIAS\MetaData\Elements\Markers\DELETE, and ILIAS\Data\Description\NULL.

◆ testPrepareDelete_002()

ILIAS\MetaData\Manipulator\ManipulatorTest::testPrepareDelete_002 ( )

Definition at line 920 of file ManipulatorTest.php.

920 : void
921 {
922 $manipulator = new Manipulator(
923 new NullScaffoldProvider(),
924 $this->getMarkerFactoryMock(),
926 $this->getPathFactoryMock(),
927 new NullPathUtilitiesFactory()
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',
984 null,
985 '',
986 [
987 $expected_element_target
988 ]
989 );
990
991 $expected_element_general = $this->createExpectedValuesArray(
992 2,
993 0,
994 'general',
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 }

References Vendor\Package\$e, ILIAS\MetaData\Paths\Filters\DATA, and ILIAS\Data\Description\NULL.

◆ testPrepareForceCreate01()

ILIAS\MetaData\Manipulator\ManipulatorTest::testPrepareForceCreate01 ( )

Definition at line 1586 of file ManipulatorTest.php.

1586 : 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',
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 }

References Vendor\Package\$e, ILIAS\MetaData\Paths\Filters\DATA, ILIAS\Data\Description\NULL, and ILIAS\MetaData\Paths\Steps\SUPER.

◆ testPrepareForceCreate02()

ILIAS\MetaData\Manipulator\ManipulatorTest::testPrepareForceCreate02 ( )

Definition at line 1734 of file ManipulatorTest.php.

1734 : 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 }

References Vendor\Package\$e, ILIAS\MetaData\Paths\Filters\DATA, and ILIAS\Data\Description\NULL.


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