70 : Data
71 {
72 $format = $this->createMock(DateFormat::class);
73 $format->method('applyTo')->willReturnCallback(function (\DateTimeImmutable $arg) {
74 return $arg->format('d:m:Y');
75 });
76
77 $util = new class ($format) extends NullUtilities {
78 protected DateFormat $format;
79
81 {
82 $this->format = $format;
83 }
84
85 public function getUserDateFormat(): DateFormat
86 {
87 return $this->format;
88 }
89
90 public function txt(string $key): string
91 {
92 return 'translated ' . $key;
93 }
94 };
95
96 $helper = new class () extends NullDataHelper {
97 public function durationToIterator(
string $duration): \Generator
98 {
100 if ($v === '') {
101 yield null;
102 } else {
103 yield $v;
104 }
105 }
106 }
107
108 public function datetimeToObject(
string $datetime): \DateTimeImmutable
109 {
110 return new \DateTimeImmutable(
$datetime);
111 }
112 };
113
114 $vocab_presentation = new class () extends NullVocabulariesPresentation {
115 public function presentableLabels(
116 PresentationUtilities $presentation_utilities,
117 SlotIdentifier $slot,
118 bool $with_unknown_vocab_flag,
119 string ...$values
120 ): \Generator {
121 foreach ($values as $value) {
122 yield new class ($value, $slot, $with_unknown_vocab_flag) extends NullLabelledValue {
124 protected string $value,
125 protected SlotIdentifier $slot,
126 protected bool $with_unknown_vocab_flag
127 ) {
128 }
129
130 public function value(): string
131 {
132 return $this->value;
133 }
134
135 public function label(): string
136 {
137 return 'vocab ' . $this->slot->value . ' ' .
138 $this->value . ($this->with_unknown_vocab_flag ? ' flagged' : '');
139 }
140 };
141 }
142 }
143 };
144
145 return new Data($util, $helper, $vocab_presentation);
146 }
__construct()
Constructor setup ILIAS global object @access public.