19 declare(strict_types=1);
49 protected string $name
57 protected string $name
61 public function name():
string 71 string $element_name =
'',
73 ): ConditionCheckerInterface {
74 return new class ($element_name, $fits_slot) extends NullConditionChecker {
76 protected string $element_name,
81 public function doesElementFitSlot(
84 bool $ignore_markers =
true 86 if ($element->
getDefinition()->name() !== $this->element_name) {
89 if ($slot !== $this->fits_slot) {
100 public function toElement(
102 bool $leads_to_exactly_one =
false 105 if ($leads_to_exactly_one) {
106 $string =
'exactly ';
109 return new class ($string) extends
NullPath {
111 protected string $string
117 return $this->string;
122 public function betweenElements(
125 bool $leads_to_exactly_one =
false 128 if ($leads_to_exactly_one) {
129 $string =
'exactly ';
132 return new class ($string) extends
NullPath {
134 protected string $string
140 return $this->string;
148 string $expected_path =
'',
149 string $expected_start_element_name =
'',
152 return new class ($expected_path, $expected_start_element_name, $returned_element) extends
NullNavigatorFactory {
154 protected string $expected_path,
155 protected string $expected_start_element_name,
163 $path->
toString() !== $this->expected_path &&
164 $start_element->
getDefinition()->name() !== $this->expected_start_element_name
166 throw new \Exception(
'wrong path or element name');
168 return new class ($this->expected_element) extends
NullNavigator {
176 return $this->leads_to;
184 string $expected_path =
'',
185 array $identifiers = [],
186 array $condition_paths_by_identifer = [],
187 array $condition_values_by_identifer = []
189 return new class ($expected_path, $identifiers, $condition_paths_by_identifer, $condition_values_by_identifer) extends
NullHandler {
191 protected string $expected_path,
192 protected array $identifiers,
193 protected array $condition_paths_by_identifer,
194 protected array $condition_values_by_identifer
198 public function allSlotsForPath(
PathInterface $path_to_element): \Generator
200 if ($path_to_element->
toString() !== $this->expected_path) {
201 throw new \Exception(
'wrong path');
203 yield
from $this->identifiers;
206 public function identiferFromPathAndCondition(
209 ?
string $condition_value
211 if ($path_to_element->
toString() !== $this->expected_path) {
212 throw new \Exception(
'wrong path');
214 foreach ($this->identifiers as $identifier) {
216 ($this->condition_paths_by_identifer[$identifier->value] ??
null) !== $path_to_condition->
toString() ||
217 ($this->condition_values_by_identifer[$identifier->value] ??
null) !== $condition_value
226 public function isSlotConditional(
Identifier $identifier):
bool 228 return isset($this->condition_paths_by_identifer[$identifier->value]) &&
229 isset($this->condition_values_by_identifer[$identifier->value]);
234 $condition_path = $this->condition_paths_by_identifer[$identifier->value] ??
null;
235 if ($condition_path === null) {
241 protected string $condition_path
247 return new class ($this->condition_path) extends
NullPath {
249 protected string $string
255 return $this->string;
273 [Identifier::EDUCATIONAL_CONTEXT, Identifier::GENERAL_STRUCTURE, Identifier::LIFECYCLE_STATUS]
278 #[\PHPUnit\Framework\Attributes\DataProvider('slotsForElementWithoutConditionProvider')] 280 string $element_name,
281 array $expected_identifiers
284 $this->
getMockHandler(
'to ' . $element_name, $expected_identifiers),
289 $element = self::getMockElement($element_name);
291 $actual_identifiers = iterator_to_array($helper->slotsForElementWithoutCondition($element));
293 $this->assertSame($expected_identifiers, $actual_identifiers);
306 [Identifier::EDUCATIONAL_CONTEXT, Identifier::GENERAL_STRUCTURE, Identifier::LIFECYCLE_STATUS],
311 [Identifier::EDUCATIONAL_CONTEXT, Identifier::GENERAL_STRUCTURE, Identifier::LIFECYCLE_STATUS],
312 Identifier::GENERAL_STRUCTURE
317 #[\PHPUnit\Framework\Attributes\DataProvider('slotsForElementProvider')] 319 string $element_name,
320 array $all_identifiers,
329 $element = self::getMockElement($element_name);
331 $actual_identifier = $helper->slotForElement($element);
333 $this->assertSame($matching_identifier ??
Identifier::NULL, $actual_identifier);
341 'element in condition',
350 'element in condition',
352 [Identifier::EDUCATIONAL_CONTEXT, Identifier::GENERAL_STRUCTURE, Identifier::LIFECYCLE_STATUS],
359 'element in condition',
361 [Identifier::EDUCATIONAL_CONTEXT, Identifier::GENERAL_STRUCTURE, Identifier::LIFECYCLE_STATUS],
362 [Identifier::GENERAL_STRUCTURE->value =>
'from some element to element in condition'],
363 [Identifier::GENERAL_STRUCTURE->value =>
'condition value'],
364 Identifier::GENERAL_STRUCTURE
368 'element in condition',
370 [Identifier::EDUCATIONAL_CONTEXT, Identifier::GENERAL_STRUCTURE, Identifier::LIFECYCLE_STATUS],
371 [Identifier::GENERAL_STRUCTURE->value =>
'from some element to element in condition'],
372 [Identifier::GENERAL_STRUCTURE->value =>
'condition value'],
377 'wrong element in condition',
379 [Identifier::EDUCATIONAL_CONTEXT, Identifier::GENERAL_STRUCTURE, Identifier::LIFECYCLE_STATUS],
380 [Identifier::GENERAL_STRUCTURE->value =>
'from some element to element in condition'],
381 [Identifier::GENERAL_STRUCTURE->value =>
'condition value'],
386 'element in condition',
388 [Identifier::EDUCATIONAL_CONTEXT, Identifier::GENERAL_STRUCTURE, Identifier::LIFECYCLE_STATUS],
389 [Identifier::GENERAL_STRUCTURE->value =>
'from some element to element in condition', Identifier::LIFECYCLE_STATUS->value =>
'different path'],
390 [Identifier::GENERAL_STRUCTURE->value =>
'condition value', Identifier::LIFECYCLE_STATUS->value =>
'different value'],
391 Identifier::GENERAL_STRUCTURE
396 #[\PHPUnit\Framework\Attributes\DataProvider('potentialSlotForElementByConditionProvider')] 398 string $element_name,
399 string $element_in_condition_name,
400 string $condition_value,
401 array $all_identifiers,
402 array $condition_paths_by_identifer,
403 array $condition_values_by_identifer,
407 $this->
getMockHandler(
'to ' . $element_name, $all_identifiers, $condition_paths_by_identifer, $condition_values_by_identifer),
412 $element = self::getMockElement($element_name);
413 $element_in_condition = self::getMockElement($element_in_condition_name);
415 $actual_identifier = $helper->potentialSlotForElementByCondition(
417 $element_in_condition,
421 $this->assertSame($matching_identifier ??
Identifier::NULL, $actual_identifier);
426 $el1 = self::getMockElement(
'el1');
427 $el2 = self::getMockElement(
'el2');
428 $el3 = self::getMockElement(
'el3');
429 $other_element = self::getMockElement(
'other_element');
434 Identifier::EDUCATIONAL_CONTEXT,
442 Identifier::EDUCATIONAL_CONTEXT,
450 Identifier::EDUCATIONAL_CONTEXT,
458 Identifier::EDUCATIONAL_CONTEXT,
466 #[\PHPUnit\Framework\Attributes\DataProvider('findElementOfConditionProvider')] 468 string $element_name,
473 ?
string $expected_element_name
475 $condition_paths_by_identifer = [];
476 $condition_values_by_identifer = [];
478 $condition_paths_by_identifer[$identifier->value] =
'some path';
479 $condition_values_by_identifer[$identifier->value] =
'some value';
482 $this->
getMockHandler(
'', [$identifier], $condition_paths_by_identifer, $condition_values_by_identifer),
488 $found = $helper->findElementOfCondition(
490 self::getMockElement($element_name),
494 $this->assertSame($expected_element_name, $found?->getDefinition()?->name());
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
__construct()
Constructor setup ILIAS global object public.