19declare(strict_types=1);
23use PHPUnit\Framework\TestCase;
47 protected bool $active,
53 public function isActive(): bool
58 public function type():
Type
63 public function id(): string
76 foreach ($ids as
$id) {
77 $result[] = $this->getVocabulary($active,
$id);
84 return new class ($vocabulary) extends NullCopyrightBridge {
91 return $this->vocabulary;
98 return new class ($vocabularies) extends NullControlledRepo {
99 public function __construct(
protected array $vocabularies)
105 foreach ($this->vocabularies as $vocabulary) {
106 if ($vocab_id === $vocabulary->id()) {
113 public function getVocabulariesForSlots(SlotIdentifier ...$slots): \Generator
115 yield
from $this->vocabularies;
118 public function getActiveVocabulariesForSlots(SlotIdentifier ...$slots): \Generator
120 foreach ($this->vocabularies as $vocabulary) {
121 if (!$vocabulary->isActive()) {
132 return new class ($vocabularies) extends NullStandardRepo {
133 public function __construct(
protected array $vocabularies)
139 foreach ($this->vocabularies as $vocabulary) {
140 if ($slot->value === $vocabulary->id()) {
147 public function getVocabularies(SlotIdentifier ...$slots): \Generator
149 yield
from $this->vocabularies;
152 public function getActiveVocabularies(SlotIdentifier ...$slots): \Generator
154 foreach ($this->vocabularies as $vocabulary) {
155 if (!$vocabulary->isActive()) {
171 foreach ($vocabs as $vocabulary) {
172 $actual_ids[] = $vocabulary->id();
174 $this->assertSame($ids, $actual_ids);
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);
185 $this->getCopyrightBridge(),
186 $this->getControlledRepo(...$active_controlled_vocabs, ...$inactive_controlled_vocabs),
187 $this->getStandardRepo(...$active_standard_vocabs, ...$inactive_standard_vocabs)
190 $vocab = $reader->vocabulary(
'something entirely different');
192 $this->assertInstanceOf(NullVocabulary::class,
$vocab);
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);
203 $this->getCopyrightBridge(),
204 $this->getControlledRepo(...$active_controlled_vocabs, ...$inactive_controlled_vocabs),
205 $this->getStandardRepo(...$active_standard_vocabs, ...$inactive_standard_vocabs)
208 $vocab = $reader->vocabulary(SlotIdentifier::RIGHTS_COST->value);
210 $this->assertSame(SlotIdentifier::RIGHTS_COST->value,
$vocab->id());
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);
221 $this->getCopyrightBridge($cp_vocab),
222 $this->getControlledRepo(...$active_controlled_vocabs, ...$inactive_controlled_vocabs),
223 $this->getStandardRepo(...$active_standard_vocabs, ...$inactive_standard_vocabs)
226 $vocab = $reader->vocabulary(SlotIdentifier::RIGHTS_DESCRIPTION->value);
228 $this->assertSame(SlotIdentifier::RIGHTS_DESCRIPTION->value,
$vocab->id());
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);
239 $this->getCopyrightBridge(),
240 $this->getControlledRepo(...$active_controlled_vocabs, ...$inactive_controlled_vocabs),
241 $this->getStandardRepo(...$active_standard_vocabs, ...$inactive_standard_vocabs)
244 $vocab = $reader->vocabulary(
'contr active 1');
246 $this->assertSame(
'contr active 1',
$vocab->id());
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');
258 $this->getCopyrightBridge($cp_vocab),
259 $this->getControlledRepo(...$active_controlled_vocabs, ...$inactive_controlled_vocabs),
260 $this->getStandardRepo(...$active_standard_vocabs, ...$inactive_standard_vocabs)
263 $this->assertVocabIDsMatch(
275 $reader->vocabulariesForSlots(SlotIdentifier::RIGHTS_COST)
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');
287 $this->getCopyrightBridge(),
288 $this->getControlledRepo(...$active_controlled_vocabs, ...$inactive_controlled_vocabs),
289 $this->getStandardRepo(...$active_standard_vocabs, ...$inactive_standard_vocabs)
292 $this->assertVocabIDsMatch(
303 $reader->vocabulariesForSlots(SlotIdentifier::RIGHTS_COST)
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');
316 $this->getCopyrightBridge($cp_vocab),
317 $this->getControlledRepo(...$active_controlled_vocabs, ...$inactive_controlled_vocabs),
318 $this->getStandardRepo(...$active_standard_vocabs, ...$inactive_standard_vocabs)
321 $this->assertVocabIDsMatch(
329 $reader->activeVocabulariesForSlots(SlotIdentifier::RIGHTS_COST)
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');
341 $this->getCopyrightBridge(),
342 $this->getControlledRepo(...$active_controlled_vocabs, ...$inactive_controlled_vocabs),
343 $this->getStandardRepo(...$active_standard_vocabs, ...$inactive_standard_vocabs)
346 $this->assertVocabIDsMatch(
353 $reader->activeVocabulariesForSlots(SlotIdentifier::RIGHTS_COST)
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');
366 $this->getCopyrightBridge($cp_vocab),
367 $this->getControlledRepo(...$active_controlled_vocabs, ...$inactive_controlled_vocabs),
368 $this->getStandardRepo(...$active_standard_vocabs, ...$inactive_standard_vocabs)
371 $this->assertVocabIDsMatch(
378 $reader->activeVocabulariesForSlots(SlotIdentifier::RIGHTS_COST)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
__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