ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\MetaData\Vocabularies\Dispatch\ReaderTest Class Reference
+ Inheritance diagram for ILIAS\MetaData\Vocabularies\Dispatch\ReaderTest:
+ Collaboration diagram for ILIAS\MetaData\Vocabularies\Dispatch\ReaderTest:

Public Member Functions

 getVocabsWithIDs (bool $active, string ... $ids)
 
 testVocabularyInvalidVocabID ()
 
 testVocabularyInvalidVocabIDFromStandardSlot ()
 
 testVocabularyInvalidVocabIDFromCopyrightSlot ()
 
 testVocabularyInvalidVocabIDFromControlledVocabulary ()
 
 testVocabulariesForSlots ()
 
 testVocabulariesForSlotsNoCopyright ()
 
 testActiveVocabulariesForSlots ()
 
 testActiveVocabulariesForSlotsNoCopyright ()
 
 testActiveVocabulariesForSlotsCopyrightVocabInactive ()
 

Protected Member Functions

 getVocabulary (bool $active, string $id='', Type $type=Type::NULL)
 
 getCopyrightBridge (?VocabularyInterface $vocabulary=null)
 
 getControlledRepo (VocabularyInterface ... $vocabularies)
 
 getStandardRepo (VocabularyInterface ... $vocabularies)
 
 assertVocabIDsMatch (array $ids, \Generator $vocabs)
 

Detailed Description

Definition at line 38 of file ReaderTest.php.

Member Function Documentation

◆ assertVocabIDsMatch()

ILIAS\MetaData\Vocabularies\Dispatch\ReaderTest::assertVocabIDsMatch ( array  $ids,
\Generator  $vocabs 
)
protected
Parameters
string[]$ids
VocabularyInterface[]$vocabs

Definition at line 168 of file ReaderTest.php.

168 : void
169 {
170 $actual_ids = [];
171 foreach ($vocabs as $vocabulary) {
172 $actual_ids[] = $vocabulary->id();
173 }
174 $this->assertSame($ids, $actual_ids);
175 }

◆ getControlledRepo()

ILIAS\MetaData\Vocabularies\Dispatch\ReaderTest::getControlledRepo ( VocabularyInterface ...  $vocabularies)
protected

Definition at line 96 of file ReaderTest.php.

96 : ControlledRepo
97 {
98 return new class ($vocabularies) extends NullControlledRepo {
99 public function __construct(protected array $vocabularies)
100 {
101 }
102
103 public function getVocabulary(string $vocab_id): VocabularyInterface
104 {
105 foreach ($this->vocabularies as $vocabulary) {
106 if ($vocab_id === $vocabulary->id()) {
107 return $vocabulary;
108 }
109 }
110 return new NullVocabulary();
111 }
112
113 public function getVocabulariesForSlots(SlotIdentifier ...$slots): \Generator
114 {
115 yield from $this->vocabularies;
116 }
117
118 public function getActiveVocabulariesForSlots(SlotIdentifier ...$slots): \Generator
119 {
120 foreach ($this->vocabularies as $vocabulary) {
121 if (!$vocabulary->isActive()) {
122 continue;
123 }
124 yield $vocabulary;
125 }
126 }
127 };
128 }
getVocabulary(bool $active, string $id='', Type $type=Type::NULL)
Definition: ReaderTest.php:40
__construct()
Constructor setup ILIAS global object @access public.
Definition: class.ilias.php:76

References ILIAS\GlobalScreen\Provider\__construct(), and ILIAS\ResourceStorage\Flavour\Machine\DefaultMachines\from().

+ Here is the call graph for this function:

◆ getCopyrightBridge()

ILIAS\MetaData\Vocabularies\Dispatch\ReaderTest::getCopyrightBridge ( ?VocabularyInterface  $vocabulary = null)
protected

Definition at line 82 of file ReaderTest.php.

82 : CopyrightBridge
83 {
84 return new class ($vocabulary) extends NullCopyrightBridge {
85 public function __construct(protected ?VocabularyInterface $vocabulary)
86 {
87 }
88
89 public function vocabulary(SlotIdentifier $slot): ?VocabularyInterface
90 {
91 return $this->vocabulary;
92 }
93 };
94 }

References ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

◆ getStandardRepo()

ILIAS\MetaData\Vocabularies\Dispatch\ReaderTest::getStandardRepo ( VocabularyInterface ...  $vocabularies)
protected

Definition at line 130 of file ReaderTest.php.

130 : StandardRepo
131 {
132 return new class ($vocabularies) extends NullStandardRepo {
133 public function __construct(protected array $vocabularies)
134 {
135 }
136
137 public function getVocabulary(SlotIdentifier $slot): VocabularyInterface
138 {
139 foreach ($this->vocabularies as $vocabulary) {
140 if ($slot->value === $vocabulary->id()) {
141 return $vocabulary;
142 }
143 }
144 return new NullVocabulary();
145 }
146
147 public function getVocabularies(SlotIdentifier ...$slots): \Generator
148 {
149 yield from $this->vocabularies;
150 }
151
152 public function getActiveVocabularies(SlotIdentifier ...$slots): \Generator
153 {
154 foreach ($this->vocabularies as $vocabulary) {
155 if (!$vocabulary->isActive()) {
156 continue;
157 }
158 yield $vocabulary;
159 }
160 }
161 };
162 }

References ILIAS\GlobalScreen\Provider\__construct(), and ILIAS\ResourceStorage\Flavour\Machine\DefaultMachines\from().

+ Here is the call graph for this function:

◆ getVocabsWithIDs()

ILIAS\MetaData\Vocabularies\Dispatch\ReaderTest::getVocabsWithIDs ( bool  $active,
string ...  $ids 
)
Returns
VocabularyInterface[]

Definition at line 73 of file ReaderTest.php.

73 : array
74 {
75 $result = [];
76 foreach ($ids as $id) {
77 $result[] = $this->getVocabulary($active, $id);
78 }
79 return $result;
80 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

References $id.

◆ getVocabulary()

ILIAS\MetaData\Vocabularies\Dispatch\ReaderTest::getVocabulary ( bool  $active,
string  $id = '',
Type  $type = Type::NULL 
)
protected

Definition at line 40 of file ReaderTest.php.

44 : VocabularyInterface {
45 return new class ($active, $type, $id) extends NullVocabulary {
46 public function __construct(
47 protected bool $active,
48 protected Type $type,
49 protected string $id
50 ) {
51 }
52
53 public function isActive(): bool
54 {
55 return $this->active;
56 }
57
58 public function type(): Type
59 {
60 return $this->type;
61 }
62
63 public function id(): string
64 {
65 return $this->id;
66 }
67 };
68 }

◆ testActiveVocabulariesForSlots()

ILIAS\MetaData\Vocabularies\Dispatch\ReaderTest::testActiveVocabulariesForSlots ( )

Definition at line 307 of file ReaderTest.php.

307 : void
308 {
309 $cp_vocab = $this->getVocabulary(true, 'cp');
310 $active_controlled_vocabs = $this->getVocabsWithIDs(true, 'contr active 1', 'contr active 2');
311 $inactive_controlled_vocabs = $this->getVocabsWithIDs(false, 'contr inactive 1', 'contr inactive 2');
312 $active_standard_vocabs = $this->getVocabsWithIDs(true, 'stand active 1', 'stand active 2');
313 $inactive_standard_vocabs = $this->getVocabsWithIDs(false, 'stand inactive 1', 'stand inactive 2');
314
315 $reader = new Reader(
316 $this->getCopyrightBridge($cp_vocab),
317 $this->getControlledRepo(...$active_controlled_vocabs, ...$inactive_controlled_vocabs),
318 $this->getStandardRepo(...$active_standard_vocabs, ...$inactive_standard_vocabs)
319 );
320
321 $this->assertVocabIDsMatch(
322 [
323 'cp',
324 'contr active 1',
325 'contr active 2',
326 'stand active 1',
327 'stand active 2'
328 ],
329 $reader->activeVocabulariesForSlots(SlotIdentifier::RIGHTS_COST)
330 );
331 }
getVocabsWithIDs(bool $active, string ... $ids)
Definition: ReaderTest.php:73
getStandardRepo(VocabularyInterface ... $vocabularies)
Definition: ReaderTest.php:130
getControlledRepo(VocabularyInterface ... $vocabularies)
Definition: ReaderTest.php:96
getCopyrightBridge(?VocabularyInterface $vocabulary=null)
Definition: ReaderTest.php:82
assertVocabIDsMatch(array $ids, \Generator $vocabs)
Definition: ReaderTest.php:168

◆ testActiveVocabulariesForSlotsCopyrightVocabInactive()

ILIAS\MetaData\Vocabularies\Dispatch\ReaderTest::testActiveVocabulariesForSlotsCopyrightVocabInactive ( )

Definition at line 357 of file ReaderTest.php.

357 : void
358 {
359 $cp_vocab = $this->getVocabulary(false, 'cp');
360 $active_controlled_vocabs = $this->getVocabsWithIDs(true, 'contr active 1', 'contr active 2');
361 $inactive_controlled_vocabs = $this->getVocabsWithIDs(false, 'contr inactive 1', 'contr inactive 2');
362 $active_standard_vocabs = $this->getVocabsWithIDs(true, 'stand active 1', 'stand active 2');
363 $inactive_standard_vocabs = $this->getVocabsWithIDs(false, 'stand inactive 1', 'stand inactive 2');
364
365 $reader = new Reader(
366 $this->getCopyrightBridge($cp_vocab),
367 $this->getControlledRepo(...$active_controlled_vocabs, ...$inactive_controlled_vocabs),
368 $this->getStandardRepo(...$active_standard_vocabs, ...$inactive_standard_vocabs)
369 );
370
371 $this->assertVocabIDsMatch(
372 [
373 'contr active 1',
374 'contr active 2',
375 'stand active 1',
376 'stand active 2'
377 ],
378 $reader->activeVocabulariesForSlots(SlotIdentifier::RIGHTS_COST)
379 );
380 }

◆ testActiveVocabulariesForSlotsNoCopyright()

ILIAS\MetaData\Vocabularies\Dispatch\ReaderTest::testActiveVocabulariesForSlotsNoCopyright ( )

Definition at line 333 of file ReaderTest.php.

333 : void
334 {
335 $active_controlled_vocabs = $this->getVocabsWithIDs(true, 'contr active 1', 'contr active 2');
336 $inactive_controlled_vocabs = $this->getVocabsWithIDs(false, 'contr inactive 1', 'contr inactive 2');
337 $active_standard_vocabs = $this->getVocabsWithIDs(true, 'stand active 1', 'stand active 2');
338 $inactive_standard_vocabs = $this->getVocabsWithIDs(false, 'stand inactive 1', 'stand inactive 2');
339
340 $reader = new Reader(
341 $this->getCopyrightBridge(),
342 $this->getControlledRepo(...$active_controlled_vocabs, ...$inactive_controlled_vocabs),
343 $this->getStandardRepo(...$active_standard_vocabs, ...$inactive_standard_vocabs)
344 );
345
346 $this->assertVocabIDsMatch(
347 [
348 'contr active 1',
349 'contr active 2',
350 'stand active 1',
351 'stand active 2'
352 ],
353 $reader->activeVocabulariesForSlots(SlotIdentifier::RIGHTS_COST)
354 );
355 }

◆ testVocabulariesForSlots()

ILIAS\MetaData\Vocabularies\Dispatch\ReaderTest::testVocabulariesForSlots ( )

Definition at line 249 of file ReaderTest.php.

249 : void
250 {
251 $cp_vocab = $this->getVocabulary(true, 'cp');
252 $active_controlled_vocabs = $this->getVocabsWithIDs(true, 'contr active 1', 'contr active 2');
253 $inactive_controlled_vocabs = $this->getVocabsWithIDs(false, 'contr inactive 1', 'contr inactive 2');
254 $active_standard_vocabs = $this->getVocabsWithIDs(true, 'stand active 1', 'stand active 2');
255 $inactive_standard_vocabs = $this->getVocabsWithIDs(false, 'stand inactive 1', 'stand inactive 2');
256
257 $reader = new Reader(
258 $this->getCopyrightBridge($cp_vocab),
259 $this->getControlledRepo(...$active_controlled_vocabs, ...$inactive_controlled_vocabs),
260 $this->getStandardRepo(...$active_standard_vocabs, ...$inactive_standard_vocabs)
261 );
262
263 $this->assertVocabIDsMatch(
264 [
265 'cp',
266 'contr active 1',
267 'contr active 2',
268 'contr inactive 1',
269 'contr inactive 2',
270 'stand active 1',
271 'stand active 2',
272 'stand inactive 1',
273 'stand inactive 2'
274 ],
275 $reader->vocabulariesForSlots(SlotIdentifier::RIGHTS_COST)
276 );
277 }

◆ testVocabulariesForSlotsNoCopyright()

ILIAS\MetaData\Vocabularies\Dispatch\ReaderTest::testVocabulariesForSlotsNoCopyright ( )

Definition at line 279 of file ReaderTest.php.

279 : void
280 {
281 $active_controlled_vocabs = $this->getVocabsWithIDs(true, 'contr active 1', 'contr active 2');
282 $inactive_controlled_vocabs = $this->getVocabsWithIDs(false, 'contr inactive 1', 'contr inactive 2');
283 $active_standard_vocabs = $this->getVocabsWithIDs(true, 'stand active 1', 'stand active 2');
284 $inactive_standard_vocabs = $this->getVocabsWithIDs(false, 'stand inactive 1', 'stand inactive 2');
285
286 $reader = new Reader(
287 $this->getCopyrightBridge(),
288 $this->getControlledRepo(...$active_controlled_vocabs, ...$inactive_controlled_vocabs),
289 $this->getStandardRepo(...$active_standard_vocabs, ...$inactive_standard_vocabs)
290 );
291
292 $this->assertVocabIDsMatch(
293 [
294 'contr active 1',
295 'contr active 2',
296 'contr inactive 1',
297 'contr inactive 2',
298 'stand active 1',
299 'stand active 2',
300 'stand inactive 1',
301 'stand inactive 2'
302 ],
303 $reader->vocabulariesForSlots(SlotIdentifier::RIGHTS_COST)
304 );
305 }

◆ testVocabularyInvalidVocabID()

ILIAS\MetaData\Vocabularies\Dispatch\ReaderTest::testVocabularyInvalidVocabID ( )

Definition at line 177 of file ReaderTest.php.

177 : void
178 {
179 $active_controlled_vocabs = $this->getVocabsWithIDs(true, 'contr active 1', 'contr active 2');
180 $inactive_controlled_vocabs = $this->getVocabsWithIDs(false, 'contr inactive 1', 'contr inactive 2');
181 $active_standard_vocabs = $this->getVocabsWithIDs(true, SlotIdentifier::GENERAL_COVERAGE->value);
182 $inactive_standard_vocabs = $this->getVocabsWithIDs(false, SlotIdentifier::RIGHTS_COST->value);
183
184 $reader = new Reader(
185 $this->getCopyrightBridge(),
186 $this->getControlledRepo(...$active_controlled_vocabs, ...$inactive_controlled_vocabs),
187 $this->getStandardRepo(...$active_standard_vocabs, ...$inactive_standard_vocabs)
188 );
189
190 $vocab = $reader->vocabulary('something entirely different');
191
192 $this->assertInstanceOf(NullVocabulary::class, $vocab);
193 }
$vocab

References $vocab.

◆ testVocabularyInvalidVocabIDFromControlledVocabulary()

ILIAS\MetaData\Vocabularies\Dispatch\ReaderTest::testVocabularyInvalidVocabIDFromControlledVocabulary ( )

Definition at line 231 of file ReaderTest.php.

231 : void
232 {
233 $active_controlled_vocabs = $this->getVocabsWithIDs(true, 'contr active 1', 'contr active 2');
234 $inactive_controlled_vocabs = $this->getVocabsWithIDs(false, 'contr inactive 1', 'contr inactive 2');
235 $active_standard_vocabs = $this->getVocabsWithIDs(true, SlotIdentifier::GENERAL_COVERAGE->value);
236 $inactive_standard_vocabs = $this->getVocabsWithIDs(false, SlotIdentifier::RIGHTS_COST->value);
237
238 $reader = new Reader(
239 $this->getCopyrightBridge(),
240 $this->getControlledRepo(...$active_controlled_vocabs, ...$inactive_controlled_vocabs),
241 $this->getStandardRepo(...$active_standard_vocabs, ...$inactive_standard_vocabs)
242 );
243
244 $vocab = $reader->vocabulary('contr active 1');
245
246 $this->assertSame('contr active 1', $vocab->id());
247 }

References $vocab.

◆ testVocabularyInvalidVocabIDFromCopyrightSlot()

ILIAS\MetaData\Vocabularies\Dispatch\ReaderTest::testVocabularyInvalidVocabIDFromCopyrightSlot ( )

Definition at line 212 of file ReaderTest.php.

212 : void
213 {
214 $cp_vocab = $this->getVocabulary(true, SlotIdentifier::RIGHTS_DESCRIPTION->value);
215 $active_controlled_vocabs = $this->getVocabsWithIDs(true, 'contr active 1', 'contr active 2');
216 $inactive_controlled_vocabs = $this->getVocabsWithIDs(false, 'contr inactive 1', 'contr inactive 2');
217 $active_standard_vocabs = $this->getVocabsWithIDs(true, SlotIdentifier::GENERAL_COVERAGE->value);
218 $inactive_standard_vocabs = $this->getVocabsWithIDs(false, SlotIdentifier::RIGHTS_COST->value);
219
220 $reader = new Reader(
221 $this->getCopyrightBridge($cp_vocab),
222 $this->getControlledRepo(...$active_controlled_vocabs, ...$inactive_controlled_vocabs),
223 $this->getStandardRepo(...$active_standard_vocabs, ...$inactive_standard_vocabs)
224 );
225
226 $vocab = $reader->vocabulary(SlotIdentifier::RIGHTS_DESCRIPTION->value);
227
228 $this->assertSame(SlotIdentifier::RIGHTS_DESCRIPTION->value, $vocab->id());
229 }

References $vocab.

◆ testVocabularyInvalidVocabIDFromStandardSlot()

ILIAS\MetaData\Vocabularies\Dispatch\ReaderTest::testVocabularyInvalidVocabIDFromStandardSlot ( )

Definition at line 195 of file ReaderTest.php.

195 : void
196 {
197 $active_controlled_vocabs = $this->getVocabsWithIDs(true, 'contr active 1', 'contr active 2');
198 $inactive_controlled_vocabs = $this->getVocabsWithIDs(false, 'contr inactive 1', 'contr inactive 2');
199 $active_standard_vocabs = $this->getVocabsWithIDs(true, SlotIdentifier::GENERAL_COVERAGE->value);
200 $inactive_standard_vocabs = $this->getVocabsWithIDs(false, SlotIdentifier::RIGHTS_COST->value);
201
202 $reader = new Reader(
203 $this->getCopyrightBridge(),
204 $this->getControlledRepo(...$active_controlled_vocabs, ...$inactive_controlled_vocabs),
205 $this->getStandardRepo(...$active_standard_vocabs, ...$inactive_standard_vocabs)
206 );
207
208 $vocab = $reader->vocabulary(SlotIdentifier::RIGHTS_COST->value);
209
210 $this->assertSame(SlotIdentifier::RIGHTS_COST->value, $vocab->id());
211 }

References $vocab.


The documentation for this class was generated from the following file: