19 declare(strict_types=1);
    73         return new class ($set_root) extends 
NullSet {
    85                 return $this->set_root;
    93             public function getScaffoldsForElement(
ElementInterface $element): \Generator
   109                 return $this->test->getScaffoldProviderMock();
   116         return new class ($action, $data_value) extends 
NullMarker {
   117             public function __construct(
protected Action $action, 
protected string $data_value)
   121             public function action(): 
Action   123                 return $this->action;
   126             public function dataValue(): 
string   128                 return $this->data_value;
   142                 return $this->test->getMarkerMock($action, $data_value);
   153             protected array $my_elements;
   157             protected array $steps;
   158             protected int $step_index;
   162                 $this->my_elements = [$this->start_element];
   163                 $this->steps = iterator_to_array($path->
steps());
   164                 $this->step_index = -1;
   167             protected function filterElements(): 
void   169                 foreach ($this->currentStep()->filters() as $filter) {
   170                     if ($filter->type() === FilterType::NULL) {
   173                     if ($filter->type() === FilterType::MDID) {
   175                         foreach ($this->my_elements as $element) {
   176                             foreach ($filter->values() as $value) {
   177                                 if ($element->getMDID() === $value) {
   178                                     $elements[] = $element;
   183                         $this->my_elements = $elements;
   188                         foreach ($this->my_elements as $element) {
   189                             foreach ($filter->values() as $value) {
   190                                 if ($element->getData()->value() === $value) {
   191                                     $elements[] = $element;
   196                         $this->my_elements = $elements;
   199                     if ($filter->type() === FilterType::INDEX) {
   201                         foreach ($filter->values() as $value) {
   202                             $value = (
int) $value;
   203                             if (0 <= $value && $value < count($this->my_elements)) {
   204                                 $elements[] = $this->my_elements[$value];
   207                         $this->my_elements = $elements;
   213             public function elementsAtFinalStep(): \Generator
   215                 $current = clone $this;
   216                 while ($current->hasNextStep()) {
   217                     $current = $current->nextStep();
   219                 yield 
from $current->my_elements;
   224                 $element_count = count($this->my_elements);
   225                 return ($element_count === 0) ? null : $this->my_elements[$element_count - 1];
   230                 if (!$this->hasNextStep()) {
   233                 $clone = clone $this;
   234                 $clone->my_elements = [];
   235                 $clone->step_index = $clone->step_index + 1;
   236                 foreach ($this->my_elements as $element) {
   237                     array_push($clone->my_elements, ...$element->getSubElements());
   239                 $clone->filterElements();
   245                 return (0 <= $this->step_index && $this->step_index < count($this->steps)) ? $this->steps[$this->step_index] : null;
   250                 $final_elements = iterator_to_array($this->elementsAtFinalStep());
   251                 $final_elements_count = count($final_elements);
   252                 return $final_elements_count > 0 ? $final_elements[$final_elements_count - 1] : null;
   257                 if (!$this->hasPreviousStep()) {
   260                 $clone = clone $this;
   261                 $clone->my_elements = [];
   262                 $clone->step_index = $clone->step_index - 1;
   263                 foreach ($this->my_elements as $element) {
   264                     $clone->my_elements[] = $element->getSuperElement();
   269             public function hasNextStep(): 
bool   271                 return ($this->step_index + 1) < count($this->steps);
   274             public function hasPreviousStep(): 
bool   276                 return ($this->step_index - 1) >= -1;
   279             public function hasElements(): 
bool   281                 return count($this->my_elements) > 0;
   284             public function elements(): \Generator
   286                 yield 
from $this->my_elements;
   297         $path_conditions = [];
   298         $collected_steps = [];
   300         foreach ($path->
steps() as $step) {
   303                 $condition = array_pop($collected_steps);
   304                 $target = $collected_steps[count($collected_steps) - 1];
   305                 $condition_path_steps = [$condition];
   307                 if (key_exists($condition->name(), $path_conditions)) {
   309                     foreach ($path_conditions[$condition->name()]->steps() as $cond_step) {
   310                         $condition_path_steps[] = $cond_step;
   313                     unset($path_conditions[$condition->name()]);
   316                 if (key_exists($target->name(), $path_conditions)) {
   318                     foreach ($path_conditions[$target->name()]->steps() as $cond_step) {
   319                         $target_steps[] = $cond_step;
   321                     array_unshift($condition_path_steps, ...$target_steps);
   322                     unset($path_conditions[$target->name()]);
   325                 $path_conditions[$target->name()] = $this->
getPathMock(
   326                     $condition_path_steps,
   332             $collected_steps[] = $step;
   337             $this->
getPathMock($collected_steps, 
false, 
false),
   343                 protected array $path_conditons
   349                 return $this->clear_path;
   352             public function getConditionPathByStepName(
string $name): 
PathInterface   354                 if (key_exists($name, $this->path_conditons)) {
   355                     return $this->path_conditons[$name];
   357                 return $this->test->getPathMock([], 
true, 
false);
   366             $path_conditions_collection,
   377                 $navigator = $this->navigator_factory->navigator(
   378                     $this->path_conditions_collection->getConditionPathByStepName($step->
name()),
   381                 while (!is_null($navigator)) {
   382                     if (!$navigator->hasElements()) {
   385                     $navigator = $navigator->nextStep();
   392                 foreach ($roots as $root) {
   393                     if (!$this->isPathConditionMet($step, $root)) {
   402                 foreach ($roots as $root) {
   403                     if ($this->isPathConditionMet($step, $root)) {
   413                 foreach ($roots as $root) {
   414                     if ($this->isPathConditionMet($step, $root)) {
   418                 yield 
from $elements;
   432                 return $this->test->getPathBuilderMock();
   440             protected bool $is_relative;
   441             protected bool $leads_to_exactly_one_element;
   445             protected array $steps;
   449                 $this->is_relative = 
false;
   450                 $this->leads_to_exactly_one_element = 
false;
   453             public function withLeadsToExactlyOneElement(
bool $leads_to_one): 
BuilderInterface   455                 $builder = clone $this;
   456                 $builder->leads_to_exactly_one_element = $leads_to_one;
   462                 $builder = clone $this;
   463                 $builder->is_relative = $is_relative;
   469                 $builder = clone $this;
   470                 $builder->steps[] = $next_step;
   476                 return $this->test->getPathMock($this->steps, $this->is_relative, $this->leads_to_exactly_one_element);
   490                 return $this->test->getNavigatorMock($path, $start_element);
   505             public function pathConditionChecker(
   508                 return $this->test->getPathConditionCheckerMock($path_conditions_collection);
   513                 return $this->test->getPathConditionCollectionMock($path);
   520         return new class ($value, $type) extends 
NullData {
   521             public function __construct(
protected string $my_value, 
protected Type $my_type)
   525             public function value(): 
string   527                 return $this->my_value;
   530             public function type(): 
Type   532                 return $this->my_type;
   542         return new class ($name, $data_type, $is_unique) extends 
NullDefinition {
   544                 protected string $my_name,
   545                 protected Type $data_type,
   546                 protected bool $is_unique
   550             public function name(): 
string   552                 return $this->my_name;
   555             public function dataType(): 
Type   557                 return $this->data_type;
   560             public function unique(): 
bool   562                 return $this->is_unique;
   567     public function getElementMock(
   571         bool $is_unique = 
false   573         return new class ($this, $mdid, $value, $type, $is_unique) extends 
NullElement {
   581             protected array $children;
   585                 protected int|
NoID $mdid,
   590                 $this->marker = null;
   591                 $this->parent = null;
   592                 $this->children = [];
   593                 $this->data = $this->test->getDataMock($value, $type);
   594                 $this->definition = $this->test->getDefinitionMock(
'', $this->data->type(), $is_unique);
   597             public function getMDID(): 
int|
NoID   604                 $child->parent = $this;
   605                 $this->children[] = $child;
   610                 foreach ($children as $child) {
   611                     $this->addChild($child);
   615             public function getSubElements(): \Generator
   617                 yield 
from $this->children;
   622                 return $this->parent;
   627                 $element = $this->test->getElementMock(NoID::SCAFFOLD, $name, Type::NULL);
   628                 $this->addChild($element);
   639                 $this->marker = $factory->
marker($action, $data_value);
   640                 $element = $this->parent;
   641                 while (!is_null($element) && !$element->isMarked()) {
   642                     $current_action = ($element->isScaffold() && $action === Action::CREATE_OR_UPDATE) ? Action::CREATE_OR_UPDATE : Action::NEUTRAL;
   643                     $element->marker = $factory->
marker($current_action);
   644                     $element = $element->parent;
   650                 return $this->definition;
   656                 return $this->marker;
   659             public function isMarked(): 
bool   661                 return !is_null($this->marker);
   671         return new class ($steps, $is_relative, $leads_to_one) extends 
NullPath {
   676                 protected array $my_steps,
   677                 protected bool $is_relative,
   678                 protected bool $leads_to_one
   682             public function leadsToExactlyOneElement(): 
bool   684                 return $this->leads_to_one;
   687             public function isRelative(): 
bool   689                 return $this->is_relative;
   692             public function steps(): \Generator
   694                 yield 
from $this->my_steps;
   704         return new class ($step_name, $filter) extends 
NullStep {
   711                 return $this->step_name;
   714             public function filters(): \Generator
   716                 yield 
from $this->my_filter;
   723         return new class ($filter_type, $values) extends 
NullFilter {
   730                 return $this->filter_type;
   733             public function values(): \Generator
   735                 yield 
from $this->my_values;
   741         int $expected_child_count,
   742         int|
NoID $expected_id,
   743         string $expected_element_data_value,
   744         Type $expected_data_type = Type::NULL,
   745         ?
Action $expected_marker_action = null,
   746         string $exptected_marker_value = 
'',
   747         array $expected_child_values = [],
   750             'expected_child_count' => $expected_child_count,
   751             'expected_id' => $expected_id,
   752             'expected_element_data_value' => $expected_element_data_value,
   753             'expected_data_type' => $expected_data_type,
   754             'expected_marker_action' => $expected_marker_action,
   755             'expected_marker_value' => $exptected_marker_value,
   756             'children' => $expected_child_values
   760     protected function myAssertElement(
   762         array $expected_values
   772         $expected_child_count = $expected_values[
'expected_child_count'];
   773         $expected_id = $expected_values[
'expected_id'];
   774         $expected_element_data_value = $expected_values[
'expected_element_data_value'];
   775         $expected_data_type = $expected_values[
'expected_data_type'];
   776         $expected_marker_action = $expected_values[
'expected_marker_action'];
   777         $expected_marker_value = $expected_values[
'expected_marker_value'];
   778         $msg = 
'Failed during check of element with data value: ' . $element_to_check->
getData()->value()
   779             . 
', and with NoID: ' . ($element_to_check->
getMDID() instanceof 
NoID ? $element_to_check->
getMDID()->value : $element_to_check->
getMDID());
   780         if (is_null($expected_marker_action)) {
   781             $this->assertSame(null, $element_to_check->
getMarker(), $msg);
   783         if (!is_null($expected_marker_action)) {
   784             $this->assertNotSame(null, $element_to_check->
getMarker(), $msg);
   785             $this->assertSame($expected_marker_action, $element_to_check->
getMarker()->action(), $msg);
   786             $this->assertSame($expected_marker_value, $element_to_check->
getMarker()->dataValue(), $msg);
   788         $this->assertSame($expected_child_count, count(iterator_to_array($element_to_check->
getSubElements())), $msg);
   789         $this->assertSame($expected_id, $element_to_check->
getMDID(), $msg);
   790         $this->assertSame($expected_element_data_value, $element_to_check->
getData()->value(), $msg);
   791         $this->assertSame($expected_data_type, $element_to_check->
getData()->type(), $msg);
   794     protected function myAssertTree(
ElementInterface $root, array $expected_root_values)
   801         $expected_values = [$expected_root_values];
   802         while (count($elements) > 0) {
   803             $this->assertSame(count($elements), count($expected_values), 
'Bad test value initializion');
   804             $current_element = array_pop($elements);
   805             $current_expected_values = array_pop($expected_values);
   806             $this->myAssertElement($current_element, $current_expected_values);
   807             array_push($elements, ...$current_element->getSubElements());
   808             array_push($expected_values, ...$current_expected_values[
'children']);
   822         $element_root = $this->getElementMock(NoID::ROOT, 
'root', Type::NULL);
   823         $element_general = $this->getElementMock(0, 
'general', Type::NULL);
   824         $element_subsection_1_0 = $this->getElementMock(1, 
'subsection_1', Type::NULL);
   825         $element_subsection_1_1 = $this->getElementMock(2, 
'subsection_1', Type::NULL);
   826         $element_target_0 = $this->getElementMock(3, 
'target', Type::STRING);
   827         $element_target_1 = $this->getElementMock(4, 
'target', Type::STRING);
   828         $element_target_2 = $this->getElementMock(5, 
'target', Type::STRING);
   830         $element_root->addChildren($element_general);
   831         $element_general->addChildren($element_subsection_1_0, $element_subsection_1_1);
   832         $element_subsection_1_0->addChildren($element_target_0);
   833         $element_subsection_1_1->addChildren($element_target_1, $element_target_2);
   854             $manipulator->prepareDelete($set, $delete_path);
   856             $this->fail($e->getMessage());
   890                 $expected_element_target_1,
   891                 $expected_element_target_2
   903                 $expected_element_target_0
   915                 $expected_element_subsection_1_0,
   916                 $expected_element_subsection_1_1
   928                 $expected_element_general
   932         $this->myAssertTree($element_root, $expected_element_root);
   945         $element_root = $this->getElementMock(NoID::ROOT, 
'root', Type::NULL);
   946         $element_general = $this->getElementMock(0, 
'general', Type::NULL);
   947         $element_subsection_1_0 = $this->getElementMock(1, 
'subsection_1', Type::NULL);
   948         $element_subsection_1_1 = $this->getElementMock(2, 
'subsection_1', Type::NULL);
   949         $element_target = $this->getElementMock(3, 
'target', Type::STRING);
   951         $element_root->addChildren($element_general);
   952         $element_general->addChildren($element_subsection_1_0, $element_subsection_1_1);
   953         $element_subsection_1_0->addChildren($element_target);
   976             $manipulator->prepareDelete($set, $delete_path);
   978             $this->fail($e->getMessage());
  1002                 $expected_element_target
  1014                 $expected_element_subsection_1_0,
  1015                 $expected_element_subsection_1_1
  1027                 $expected_element_general
  1031         $this->myAssertTree($element_root, $expected_element_root);
  1050         $element_root = $this->getElementMock(NoID::ROOT, 
'root', Type::NULL, 
true);
  1053             $manipulator->prepareCreateOrUpdate($this->
getSetMock($element_root), $path, 
'test');
  1055             $this->fail($e->getMessage());
  1063             Action::CREATE_OR_UPDATE,
  1075                 $expected_element_general
  1079         $this->myAssertTree($element_root, $expected_element_root);
  1105         $element_root = $this->getElementMock(NoID::ROOT, 
'root', Type::NULL, 
true);
  1106         $element_general = $this->getElementMock(0, 
'general', Type::NULL, 
true);
  1107         $element_special = $this->getElementMock(1, 
'special', Type::NULL, 
true);
  1109         $element_root->addChildren($element_general, $element_special);
  1112             $manipulator->prepareCreateOrUpdate($this->
getSetMock($element_root), $add_path, 
'test1', 
'test2');
  1114             $this->fail($e->getMessage());
  1122             Action::CREATE_OR_UPDATE,
  1131             Action::CREATE_OR_UPDATE,
  1140             Action::CREATE_OR_UPDATE,
  1143                 $expected_element_tag_0,
  1144                 $expected_element_tag_1
  1162                 $expected_element_tags
  1174                 $expected_element_general,
  1175                 $expected_element_special
  1179         $this->myAssertTree($element_root, $expected_element_root);
  1205         $element_root = $this->getElementMock(NoID::ROOT, 
'root', Type::NULL, 
true);
  1206         $element_general = $this->getElementMock(0, 
'general', Type::NULL, 
true);
  1207         $element_special = $this->getElementMock(1, 
'special', Type::NULL, 
true);
  1208         $element_tags = $this->getElementMock(2, 
'tags', Type::NULL, 
true);
  1209         $element_tag_0 = $this->getElementMock(3, 
'tag', Type::STRING);
  1210         $element_tag_1 = $this->getElementMock(4, 
'tag', Type::STRING);
  1211         $element_tag_2 = $this->getElementMock(5, 
'tag', Type::STRING);
  1212         $element_tag_3 = $this->getElementMock(6, 
'tag', Type::STRING);
  1214         $element_root->addChildren($element_general, $element_special);
  1215         $element_general->addChildren($element_tags);
  1216         $element_tags->addChildren($element_tag_0, $element_tag_1, $element_tag_2, $element_tag_3);
  1219             $manipulator->prepareCreateOrUpdate($this->
getSetMock($element_root), $add_path, 
'test1', 
'test2');
  1221             $this->fail($e->getMessage());
  1236             Action::CREATE_OR_UPDATE,
  1252             Action::CREATE_OR_UPDATE,
  1264                 $expected_element_tag_0,
  1265                 $expected_element_tag_1,
  1266                 $expected_element_tag_2,
  1267                 $expected_element_tag_3
  1285                 $expected_element_tags
  1297                 $expected_element_general,
  1298                 $expected_element_special
  1302         $this->myAssertTree($element_root, $expected_element_root);
  1332         $element_root = $this->getElementMock(NoID::ROOT, 
'root', Type::NULL, 
true);
  1333         $element_general = $this->getElementMock(0, 
'general', Type::NULL, 
true);
  1334         $element_special = $this->getElementMock(1, 
'special', Type::NULL, 
true);
  1335         $element_general_condition = $this->getElementMock(2, 
'general_condition', Type::NULL);
  1336         $element_tags = $this->getElementMock(3, 
'tags', Type::NULL, 
true);
  1337         $element_tag_0 = $this->getElementMock(4, 
'tag', Type::STRING);
  1338         $element_tag_1 = $this->getElementMock(5, 
'tag', Type::STRING);
  1339         $element_tag_2 = $this->getElementMock(6, 
'tag', Type::STRING);
  1340         $element_tag_3 = $this->getElementMock(7, 
'tag', Type::STRING);
  1342         $element_root->addChildren($element_general, $element_special);
  1343         $element_general->addChildren($element_general_condition, $element_tags);
  1344         $element_tags->addChildren($element_tag_0, $element_tag_1, $element_tag_2, $element_tag_3);
  1347             $manipulator->prepareCreateOrUpdate($this->
getSetMock($element_root), $add_path, 
'test1', 
'test2');
  1349             $this->fail($e->getMessage());
  1364             Action::CREATE_OR_UPDATE,
  1380             Action::CREATE_OR_UPDATE,
  1392                 $expected_element_tag_0,
  1393                 $expected_element_tag_1,
  1394                 $expected_element_tag_2,
  1395                 $expected_element_tag_3
  1419                 $expected_element_general_condition,
  1420                 $expected_element_tags
  1432                 $expected_element_general,
  1433                 $expected_element_special
  1437         $this->myAssertTree($element_root, $expected_element_root);
  1466         $element_root = $this->getElementMock(NoID::ROOT, 
'root', Type::NULL, 
true);
  1467         $element_general = $this->getElementMock(0, 
'general', Type::NULL, 
true);
  1468         $element_special = $this->getElementMock(1, 
'special', Type::NULL, 
true);
  1469         $element_general_condition = $this->getElementMock(2, 
'general_condition', Type::NULL);
  1470         $element_tags = $this->getElementMock(3, 
'tags', Type::NULL, 
true);
  1471         $element_tag_0 = $this->getElementMock(4, 
'tag', Type::STRING);
  1473         $element_root->addChildren($element_general, $element_special);
  1474         $element_general->addChildren($element_general_condition, $element_tags);
  1475         $element_tags->addChildren($element_tag_0);
  1478             $manipulator->prepareCreateOrUpdate(
  1486             $this->fail($e->getMessage());
  1494             Action::CREATE_OR_UPDATE,
  1503             Action::CREATE_OR_UPDATE,
  1512             Action::CREATE_OR_UPDATE,
  1528             Action::CREATE_OR_UPDATE,
  1537             Action::CREATE_OR_UPDATE,
  1540                 $expected_element_tags_condition,
  1541                 $expected_element_tag_1,
  1542                 $expected_element_tag_2,
  1543                 $expected_element_tag_3
  1555                 $expected_element_tag_0
  1579                 $expected_element_general_condition,
  1580                 $expected_element_tags,
  1581                 $expected_element_tags_created
  1593                 $expected_element_general,
  1594                 $expected_element_special
  1598         $this->myAssertTree($element_root, $expected_element_root);
  1627         $element_root = $this->getElementMock(NoID::ROOT, 
'root', Type::NULL, 
true);
  1628         $element_general = $this->getElementMock(0, 
'general', Type::NULL, 
true);
  1629         $element_special = $this->getElementMock(1, 
'special', Type::NULL, 
true);
  1630         $element_general_condition = $this->getElementMock(2, 
'general_condition', Type::NULL);
  1631         $element_tags = $this->getElementMock(3, 
'tags', Type::NULL, 
true);
  1632         $element_tag_0 = $this->getElementMock(4, 
'tag', Type::STRING);
  1633         $element_tags_condition = $this->getElementMock(5, 
'tags_condition', Type::NULL, 
true);
  1635         $element_root->addChildren($element_general, $element_special);
  1636         $element_general->addChildren($element_general_condition, $element_tags);
  1637         $element_tags->addChildren($element_tag_0, $element_tags_condition);
  1640             $manipulator->prepareForceCreate(
  1648             $this->fail($e->getMessage());
  1656             Action::CREATE_OR_UPDATE,
  1665             Action::CREATE_OR_UPDATE,
  1674             Action::CREATE_OR_UPDATE,
  1700                 $expected_element_tag_0,
  1701                 $expected_element_tags_condition,
  1702                 $expected_element_tag_1,
  1703                 $expected_element_tag_2,
  1704                 $expected_element_tag_3
  1728                 $expected_element_general_condition,
  1729                 $expected_element_tags
  1741                 $expected_element_general,
  1742                 $expected_element_special
  1746         $this->myAssertTree($element_root, $expected_element_root);
  1771         $element_root = $this->getElementMock(NoID::ROOT, 
'root', Type::NULL, 
true);
  1772         $element_general = $this->getElementMock(0, 
'general', Type::NULL, 
true);
  1773         $element_tags = $this->getElementMock(1, 
'tags', Type::NULL, 
true);
  1774         $element_tag_0 = $this->getElementMock(2, 
'tag', Type::STRING);
  1776         $element_root->addChildren($element_general);
  1777         $element_general->addChildren($element_tags);
  1778         $element_tags->addChildren($element_tag_0);
  1781             $manipulator->prepareForceCreate(
  1789             $this->fail($e->getMessage());
  1797             Action::CREATE_OR_UPDATE,
  1806             Action::CREATE_OR_UPDATE,
  1815             Action::CREATE_OR_UPDATE,
  1834                 $expected_element_tag_0,
  1835                 $expected_element_tag_1,
  1836                 $expected_element_tag_2,
  1837                 $expected_element_tag_3
  1849                 $expected_element_tags
  1861                 $expected_element_general
  1865         $this->myAssertTree($element_root, $expected_element_root);
 
__construct()
Constructor setup ILIAS global object  public.