19declare(strict_types=1);
34use PHPUnit\Framework\TestCase;
45 return new class ($name) extends
NullStep {
63 bool $leads_exactly_to_one
65 return new class ($steps, $is_relative, $leads_exactly_to_one) extends
NullPath {
70 protected array $steps,
71 protected bool $is_relative,
72 protected bool $leads_exactly_to_one
76 public function isRelative(): bool
78 return $this->is_relative;
81 public function leadsToExactlyOneElement(): bool
83 return $this->leads_exactly_to_one;
86 public function steps(): \Generator
88 yield
from $this->steps;
98 array $step_conditions_dict
106 protected array $conditions
112 return $this->path_without_conditions;
115 public function getConditionPathByStepName(
string $name):
PathInterface
117 if (!key_exists($name, $this->conditions)) {
120 return $this->conditions[$name];
129 array $steps_has_elements
132 protected
int $index;
136 public function __construct(
protected array $step_has_elements)
143 $clone = clone $this;
145 if ($clone->index >= count($this->step_has_elements)) {
151 public function previousStep(): ?NavigatorInterface
153 $clone = clone $this;
155 if ($clone->index < 0) {
161 public function hasNextStep(): bool
163 return $this->index < (count($this->step_has_elements) - 1);
166 public function hasPreviousStep(): bool
168 return $this->index > 0;
171 public function hasElements(): bool
173 return $this->index === -1 || $this->step_has_elements[$this->index];
188 protected function stepsToBoolArray(
StepInterface ...$steps): array
191 foreach ($steps as $step) {
192 $step_str = $step->name() instanceof
StepToken ? $step->name()->value : $step->name();
193 $has_elements[] = str_ends_with($step_str,
'has_elements');
195 return $has_elements;
200 return $this->test->getNavigatorMock($this->stepsToBoolArray(...
$path->steps()));
207 $path_without_conditions = $this->getPathMock(
209 $this->getStepMock(
'start'),
210 $this->getStepMock(
'step1'),
211 $this->getStepMock(
'step2'),
212 $this->getStepMock(
'end'),
219 $this->getPathConditionsCollectionMock(
220 $path_without_conditions,
223 $this->getNavigatorFactoryMock()
227 $path_checker->isPathConditionMet($this->getStepMock(
'start'), $this->getElementMock())
230 $path_checker->isPathConditionMet($this->getStepMock(
'step1'), $this->getElementMock())
233 $path_checker->isPathConditionMet($this->getStepMock(
'step2'), $this->getElementMock())
236 $path_checker->isPathConditionMet($this->getStepMock(
'end'), $this->getElementMock())
239 $path_checker->isPathConditionMet($this->getStepMock(
'not_a_step'), $this->getElementMock())
245 $path_without_conditions = $this->getPathMock(
247 $this->getStepMock(
'start'),
248 $this->getStepMock(
'step1'),
249 $this->getStepMock(
'step2'),
250 $this->getStepMock(
'end'),
256 $path_conditions = $this->getPathConditionsCollectionMock(
257 $path_without_conditions,
259 'start' => $this->getPathMock(
261 $this->getStepMock(
'has_elements')
266 'step1' => $this->getPathMock(
268 $this->getStepMock(
'has_elements'),
269 $this->getStepMock(
'has_elements')
274 'step2' => $this->getPathMock(
276 $this->getStepMock(
'has_elements'),
277 $this->getStepMock(
'no_elements')
282 'end' => $this->getPathMock(
284 $this->getStepMock(
'no_elements')
294 $this->getNavigatorFactoryMock()
298 $path_checker->isPathConditionMet($this->getStepMock(
'start'), $this->getElementMock())
301 $path_checker->isPathConditionMet($this->getStepMock(
'step1'), $this->getElementMock())
304 $path_checker->isPathConditionMet($this->getStepMock(
'step2'), $this->getElementMock())
307 $path_checker->isPathConditionMet($this->getStepMock(
'end'), $this->getElementMock())
310 $path_checker->isPathConditionMet($this->getStepMock(
'not_a_step'), $this->getElementMock())
__construct()
Constructor setup ILIAS global object @access public.
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc