19 declare(strict_types=1);
37 bool $allows_custom_inputs =
false,
41 return new class ($allows_custom_inputs, $source, $values) extends
NullVocabulary {
43 protected bool $allows_custom_inputs,
44 protected string $source,
45 protected array $values
49 public function allowsCustomInputs():
bool 51 return $this->allows_custom_inputs;
54 public function source():
string 59 public function values(): \Generator
61 yield
from $this->values;
70 return new class ($expected_slot, $returned_vocabularies) extends
NullReader {
73 protected array $returned_vocabularies
77 public function activeVocabulariesForSlots(
Identifier ...$slots): \Generator
79 if (count($slots) !== 1 && $slots[0] !== $this->expected_slot) {
80 throw new \Exception(
'invalid slot!');
82 yield
from $this->returned_vocabularies;
90 public array $find_element_of_condition_args = [];
91 public array $slot_for_element_args = [];
92 public array $slots_for_element_without_condition_args = [];
93 public array $potential_slot_for_element_by_condition_args = [];
95 public function findElementOfCondition(
100 $this->find_element_of_condition_args[] = [
102 'element' => $element,
103 'all_elements' => $all_elements
110 $this->slot_for_element_args[] = [
111 'element' => $element
116 public function slotsForElementWithoutCondition(
ElementInterface $element): \Generator
118 $this->slots_for_element_without_condition_args[] = [
119 'element' => $element
124 public function potentialSlotForElementByCondition(
129 $this->potential_slot_for_element_by_condition_args[] = [
130 'element' => $element,
131 'element_in_condition' => $element_in_condition,
148 $adapter->findElementOfCondition(
149 Identifier::EDCUCATIONAL_INTENDED_END_USER_ROLE,
156 'slot' => Identifier::EDCUCATIONAL_INTENDED_END_USER_ROLE,
157 'element' => $element,
158 'all_elements' => $all_elements
160 $helper->find_element_of_condition_args
172 $adapter->slotForElement($element);
175 [[
'element' => $element]],
176 $helper->slot_for_element_args
188 iterator_to_array($adapter->slotsForElementWithoutCondition($element));
191 [[
'element' => $element]],
192 $helper->slots_for_element_without_condition_args
205 $adapter->potentialSlotForElementByCondition(
207 $element_in_condition,
213 'element' => $element,
214 'element_in_condition' => $element_in_condition,
215 'value' =>
'some value' 217 $helper->potential_slot_for_element_by_condition_args
225 Identifier::EDUCATIONAL_CONTEXT,
230 Identifier::EDUCATIONAL_CONTEXT,
231 [self::getMockVocabulary()],
235 Identifier::EDUCATIONAL_CONTEXT,
237 self::getMockVocabulary(),
238 self::getMockVocabulary(),
239 self::getMockVocabulary(),
240 self::getMockVocabulary()
247 #[\PHPUnit\Framework\Attributes\DataProvider('doesSlotHaveVocabulariesProvider')] 251 bool $has_vocabs_expected
258 $has_vocabs_actual = $adapter->doesSlotHaveVocabularies($slot);
260 $this->assertSame($has_vocabs_expected, $has_vocabs_actual);
267 Identifier::EDUCATIONAL_CONTEXT,
272 Identifier::EDUCATIONAL_CONTEXT,
273 [self::getMockVocabulary(
true)],
277 Identifier::EDUCATIONAL_CONTEXT,
278 [self::getMockVocabulary(
false)],
282 Identifier::EDUCATIONAL_CONTEXT,
284 self::getMockVocabulary(
true),
285 self::getMockVocabulary(
true),
286 self::getMockVocabulary(
false),
287 self::getMockVocabulary(
true)
294 #[\PHPUnit\Framework\Attributes\DataProvider('doesSlotAllowCustomInputProvider')] 298 bool $allows_custom_input_expected
305 $allows_custom_input_actual = $adapter->doesSlotAllowCustomInput($slot);
307 $this->assertSame($allows_custom_input_expected, $allows_custom_input_actual);
314 Identifier::EDUCATIONAL_CONTEXT,
320 Identifier::EDUCATIONAL_CONTEXT,
321 [self::getMockVocabulary(
false,
'')],
326 Identifier::EDUCATIONAL_CONTEXT,
327 [self::getMockVocabulary(
false,
'',
'val1',
'val2')],
332 Identifier::EDUCATIONAL_CONTEXT,
333 [self::getMockVocabulary(
false,
'',
'val1',
'some value',
'val2')],
338 Identifier::EDUCATIONAL_CONTEXT,
340 self::getMockVocabulary(
false,
'',
'val1',
'val2'),
341 self::getMockVocabulary(
false,
'',
'val3',
'val4')
347 Identifier::EDUCATIONAL_CONTEXT,
349 self::getMockVocabulary(
false,
'',
'val1',
'val2'),
350 self::getMockVocabulary(
false,
'',
'val3',
'some value',
'val4')
356 Identifier::EDUCATIONAL_CONTEXT,
358 self::getMockVocabulary(
false,
'',
'some value',
'some value'),
359 self::getMockVocabulary(
false,
'',
'some value',
'some value',
'some value')
367 #[\PHPUnit\Framework\Attributes\DataProvider('isValueInVocabulariesForSlotProvider')] 372 bool $is_in_vocabs_expected
379 $is_in_vocabs_actual = $adapter->isValueInVocabulariesForSlot($slot, $value);
381 $this->assertSame($is_in_vocabs_expected, $is_in_vocabs_actual);
388 Identifier::EDUCATIONAL_CONTEXT,
394 Identifier::EDUCATIONAL_CONTEXT,
400 Identifier::EDUCATIONAL_CONTEXT,
402 [self::getMockVocabulary(
false,
'')],
406 Identifier::EDUCATIONAL_CONTEXT,
408 [self::getMockVocabulary(
false,
'',
'val1')],
412 Identifier::EDUCATIONAL_CONTEXT,
414 [self::getMockVocabulary(
false,
'',
'val1')],
418 Identifier::EDUCATIONAL_CONTEXT,
420 [self::getMockVocabulary(
false,
'',
'val1')],
421 [
'additional value',
'val1']
424 Identifier::EDUCATIONAL_CONTEXT,
426 [self::getMockVocabulary(
false,
'',
'val1',
'val2')],
430 Identifier::EDUCATIONAL_CONTEXT,
433 self::getMockVocabulary(
false,
'',
'val1',
'val2'),
434 self::getMockVocabulary(
false,
'',
'val3',
'val4')
436 [
'val1',
'val2',
'val3',
'val4']
439 Identifier::EDUCATIONAL_CONTEXT,
442 self::getMockVocabulary(
false,
'',
'val1',
'val2'),
443 self::getMockVocabulary(
false,
'',
'val3'),
444 self::getMockVocabulary(
false,
'',
'val4',
'val5')
446 [
'val1',
'val2',
'val3',
'val4',
'val5']
449 Identifier::EDUCATIONAL_CONTEXT,
452 self::getMockVocabulary(
false,
'',
'val1',
'val2'),
453 self::getMockVocabulary(
false,
'',
'val3'),
454 self::getMockVocabulary(
false,
'',
'val4',
'val5')
456 [
'additional value',
'val1',
'val2',
'val3',
'val4',
'val5']
461 #[\PHPUnit\Framework\Attributes\DataProvider('valuesInVocabulariesForSlotProvider')] 464 ?
string $add_if_not_included,
466 array $expected_values
473 $actual_values = iterator_to_array($adapter->valuesInVocabulariesForSlot($slot, $add_if_not_included));
475 $this->assertSame($expected_values, $actual_values);
482 Identifier::EDUCATIONAL_CONTEXT,
488 Identifier::EDUCATIONAL_CONTEXT,
489 [self::getMockVocabulary(
false,
'')],
494 Identifier::EDUCATIONAL_CONTEXT,
495 [self::getMockVocabulary(
false,
'some source',
'some value')],
500 Identifier::EDUCATIONAL_CONTEXT,
501 [self::getMockVocabulary(
false,
'some source',
'some value')],
506 Identifier::EDUCATIONAL_CONTEXT,
508 self::getMockVocabulary(
false,
'source 1',
'val1.1',
'val1.2'),
509 self::getMockVocabulary(
false,
'source 2',
'val2.1',
'val2.2')
515 Identifier::EDUCATIONAL_CONTEXT,
517 self::getMockVocabulary(
false,
'source 1',
'val1.1',
'val1.2'),
518 self::getMockVocabulary(
false,
'source 2',
'val2.1',
'val2.2')
524 Identifier::EDUCATIONAL_CONTEXT,
526 self::getMockVocabulary(
false,
'source 1',
'val1.1',
'val1.2'),
527 self::getMockVocabulary(
false,
'source 2',
'val2.1',
'val2.2')
535 #[\PHPUnit\Framework\Attributes\DataProvider('sourceMapForSlotProvider')] 540 ?
string $expected_source
547 $closure = $adapter->sourceMapForSlot($slot);
548 $actual_source = $closure($value);
550 $this->assertSame($expected_source, $actual_source);
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
__construct()
Constructor setup ILIAS global object public.