19declare(strict_types=1);
23use PHPUnit\Framework\TestCase;
48 protected SlotIdentifier $slot
52 public function type():
Type
57 public function id(): string
62 public function slot(): SlotIdentifier
70 bool $is_deactivatable =
true,
71 bool $can_disallow_custom_input =
true,
72 bool $is_custom_input_applicable =
true,
73 bool $can_be_deleted =
true
77 $can_disallow_custom_input,
78 $is_custom_input_applicable,
82 protected bool $is_deactivatable,
83 protected bool $can_disallow_custom_input,
84 protected bool $is_custom_input_applicable,
85 protected bool $can_be_deleted
91 return $this->is_deactivatable;
96 return $this->can_disallow_custom_input;
99 public function isCustomInputApplicable(VocabularyInterface $vocabulary): bool
101 return $this->is_custom_input_applicable;
104 public function canBeDeleted(VocabularyInterface $vocabulary): bool
106 return $this->can_be_deleted;
113 return new class () extends NullControlledRepo {
114 public array $changes_to_active = [];
115 public array $changes_to_custom_input = [];
116 public array $exposed_deletions = [];
118 public function setActiveForVocabulary(
122 $this->changes_to_active[] = [
'id' => $vocab_id,
'active' => $active];
125 public function setCustomInputsAllowedForVocabulary(
129 $this->changes_to_custom_input[] = [
'id' => $vocab_id,
'custom_inputs' => $custom_inputs];
132 public function deleteVocabulary(
string $vocab_id):
void
134 $this->exposed_deletions[] = $vocab_id;
141 return new class () extends NullStandardRepo {
142 public array $changes_to_active = [];
144 public function activateVocabulary(SlotIdentifier $slot):
void
146 $this->changes_to_active[] = [
152 public function deactivateVocabulary(SlotIdentifier $slot):
void
154 $this->changes_to_active[] = [
165 $this->getInfos(
true,
false,
false,
true),
166 $controlled_repo = $this->getControlledRepo(),
167 $standard_repo = $this->getStandardRepo(),
169 $vocab = $this->getVocabulary(Type::STANDARD,
'', SlotIdentifier::LIFECYCLE_STATUS);
171 $actions->activate(
$vocab);
174 [[
'slot' => SlotIdentifier::LIFECYCLE_STATUS,
'active' =>
true]],
175 $standard_repo->changes_to_active
177 $this->assertEmpty($controlled_repo->changes_to_active);
178 $this->assertEmpty($controlled_repo->changes_to_custom_input);
184 $this->getInfos(
true,
true,
true,
true),
185 $controlled_repo = $this->getControlledRepo(),
186 $standard_repo = $this->getStandardRepo(),
188 $vocab = $this->getVocabulary(Type::CONTROLLED_STRING,
'vocab id', SlotIdentifier::LIFECYCLE_STATUS);
190 $actions->activate(
$vocab);
192 $this->assertEmpty($standard_repo->changes_to_active);
194 [[
'id' =>
'vocab id',
'active' =>
true]],
195 $controlled_repo->changes_to_active
197 $this->assertEmpty($controlled_repo->changes_to_custom_input);
203 $this->getInfos(
true,
false,
false,
true),
204 $controlled_repo = $this->getControlledRepo(),
205 $standard_repo = $this->getStandardRepo(),
207 $vocab = $this->getVocabulary(Type::CONTROLLED_VOCAB_VALUE,
'vocab id', SlotIdentifier::LIFECYCLE_STATUS);
209 $actions->activate(
$vocab);
211 $this->assertEmpty($standard_repo->changes_to_active);
213 [[
'id' =>
'vocab id',
'active' =>
true]],
214 $controlled_repo->changes_to_active
216 $this->assertEmpty($controlled_repo->changes_to_custom_input);
222 $this->getInfos(
false,
false,
true,
true),
223 $controlled_repo = $this->getControlledRepo(),
224 $standard_repo = $this->getStandardRepo(),
228 $actions->activate(
$vocab);
230 $this->assertEmpty($standard_repo->changes_to_active);
231 $this->assertEmpty($controlled_repo->changes_to_active);
232 $this->assertEmpty($controlled_repo->changes_to_custom_input);
238 $this->getInfos(
false,
false,
false,
true),
239 $controlled_repo = $this->getControlledRepo(),
240 $standard_repo = $this->getStandardRepo(),
242 $vocab = $this->getVocabulary(Type::STANDARD,
'', SlotIdentifier::LIFECYCLE_STATUS);
244 $this->expectException(\ilMDVocabulariesException::class);
245 $actions->deactivate(
$vocab);
251 $this->getInfos(
true,
false,
false,
true),
252 $controlled_repo = $this->getControlledRepo(),
253 $standard_repo = $this->getStandardRepo(),
255 $vocab = $this->getVocabulary(Type::STANDARD,
'', SlotIdentifier::LIFECYCLE_STATUS);
257 $actions->deactivate(
$vocab);
260 [[
'slot' => SlotIdentifier::LIFECYCLE_STATUS,
'active' =>
false]],
261 $standard_repo->changes_to_active
263 $this->assertEmpty($controlled_repo->changes_to_active);
264 $this->assertEmpty($controlled_repo->changes_to_custom_input);
270 $this->getInfos(
true,
true,
true,
true),
271 $controlled_repo = $this->getControlledRepo(),
272 $standard_repo = $this->getStandardRepo(),
274 $vocab = $this->getVocabulary(Type::CONTROLLED_STRING,
'vocab id', SlotIdentifier::LIFECYCLE_STATUS);
276 $actions->deactivate(
$vocab);
278 $this->assertEmpty($standard_repo->changes_to_active);
280 [[
'id' =>
'vocab id',
'active' =>
false]],
281 $controlled_repo->changes_to_active
283 $this->assertEmpty($controlled_repo->changes_to_custom_input);
289 $this->getInfos(
true,
false,
false,
true),
290 $controlled_repo = $this->getControlledRepo(),
291 $standard_repo = $this->getStandardRepo(),
293 $vocab = $this->getVocabulary(Type::CONTROLLED_VOCAB_VALUE,
'vocab id', SlotIdentifier::LIFECYCLE_STATUS);
295 $actions->deactivate(
$vocab);
297 $this->assertEmpty($standard_repo->changes_to_active);
299 [[
'id' =>
'vocab id',
'active' =>
false]],
300 $controlled_repo->changes_to_active
302 $this->assertEmpty($controlled_repo->changes_to_custom_input);
308 $this->getInfos(
true,
false,
true,
true),
309 $controlled_repo = $this->getControlledRepo(),
310 $standard_repo = $this->getStandardRepo(),
314 $actions->deactivate(
$vocab);
316 $this->assertEmpty($standard_repo->changes_to_active);
317 $this->assertEmpty($controlled_repo->changes_to_active);
318 $this->assertEmpty($controlled_repo->changes_to_custom_input);
324 $this->getInfos(
true,
false,
false,
true),
325 $controlled_repo = $this->getControlledRepo(),
326 $standard_repo = $this->getStandardRepo(),
328 $vocab = $this->getVocabulary(Type::STANDARD,
'', SlotIdentifier::LIFECYCLE_STATUS);
330 $this->expectException(\ilMDVocabulariesException::class);
331 $actions->allowCustomInput(
$vocab);
337 $this->getInfos(
true,
false,
true,
true),
338 $controlled_repo = $this->getControlledRepo(),
339 $standard_repo = $this->getStandardRepo(),
341 $vocab = $this->getVocabulary(Type::STANDARD,
'', SlotIdentifier::LIFECYCLE_STATUS);
343 $actions->allowCustomInput(
$vocab);
345 $this->assertEmpty($standard_repo->changes_to_active);
346 $this->assertEmpty($controlled_repo->changes_to_active);
347 $this->assertEmpty($controlled_repo->changes_to_custom_input);
353 $this->getInfos(
true,
true,
true,
true),
354 $controlled_repo = $this->getControlledRepo(),
355 $standard_repo = $this->getStandardRepo(),
357 $vocab = $this->getVocabulary(Type::CONTROLLED_STRING,
'vocab id', SlotIdentifier::LIFECYCLE_STATUS);
359 $actions->allowCustomInput(
$vocab);
361 $this->assertEmpty($standard_repo->changes_to_active);
362 $this->assertEmpty($controlled_repo->changes_to_active);
364 [[
'id' =>
'vocab id',
'custom_inputs' =>
true]],
365 $controlled_repo->changes_to_custom_input
372 $this->getInfos(
true,
false,
true,
true),
373 $controlled_repo = $this->getControlledRepo(),
374 $standard_repo = $this->getStandardRepo(),
376 $vocab = $this->getVocabulary(Type::CONTROLLED_VOCAB_VALUE,
'vocab id', SlotIdentifier::LIFECYCLE_STATUS);
378 $actions->allowCustomInput(
$vocab);
380 $this->assertEmpty($standard_repo->changes_to_active);
381 $this->assertEmpty($controlled_repo->changes_to_active);
382 $this->assertEmpty($controlled_repo->changes_to_custom_input);
388 $this->getInfos(
false,
false,
true,
true),
389 $controlled_repo = $this->getControlledRepo(),
390 $standard_repo = $this->getStandardRepo(),
394 $actions->allowCustomInput(
$vocab);
396 $this->assertEmpty($standard_repo->changes_to_active);
397 $this->assertEmpty($controlled_repo->changes_to_active);
398 $this->assertEmpty($controlled_repo->changes_to_custom_input);
404 $this->getInfos(
true,
true,
false,
true),
405 $controlled_repo = $this->getControlledRepo(),
406 $standard_repo = $this->getStandardRepo(),
408 $vocab = $this->getVocabulary(Type::STANDARD,
'', SlotIdentifier::LIFECYCLE_STATUS);
410 $this->expectException(\ilMDVocabulariesException::class);
411 $actions->disallowCustomInput(
$vocab);
417 $this->getInfos(
true,
false,
true,
true),
418 $controlled_repo = $this->getControlledRepo(),
419 $standard_repo = $this->getStandardRepo(),
421 $vocab = $this->getVocabulary(Type::STANDARD,
'', SlotIdentifier::LIFECYCLE_STATUS);
423 $this->expectException(\ilMDVocabulariesException::class);
424 $actions->disallowCustomInput(
$vocab);
430 $this->getInfos(
true,
true,
true,
true),
431 $controlled_repo = $this->getControlledRepo(),
432 $standard_repo = $this->getStandardRepo(),
434 $vocab = $this->getVocabulary(Type::STANDARD,
'', SlotIdentifier::LIFECYCLE_STATUS);
436 $actions->disallowCustomInput(
$vocab);
438 $this->assertEmpty($standard_repo->changes_to_active);
439 $this->assertEmpty($controlled_repo->changes_to_active);
440 $this->assertEmpty($controlled_repo->changes_to_custom_input);
446 $this->getInfos(
true,
true,
true,
true),
447 $controlled_repo = $this->getControlledRepo(),
448 $standard_repo = $this->getStandardRepo(),
450 $vocab = $this->getVocabulary(Type::CONTROLLED_STRING,
'vocab id', SlotIdentifier::LIFECYCLE_STATUS);
452 $actions->disallowCustomInput(
$vocab);
454 $this->assertEmpty($standard_repo->changes_to_active);
455 $this->assertEmpty($controlled_repo->changes_to_active);
457 [[
'id' =>
'vocab id',
'custom_inputs' =>
false]],
458 $controlled_repo->changes_to_custom_input
465 $this->getInfos(
true,
true,
true,
true),
466 $controlled_repo = $this->getControlledRepo(),
467 $standard_repo = $this->getStandardRepo(),
469 $vocab = $this->getVocabulary(Type::CONTROLLED_VOCAB_VALUE,
'vocab id', SlotIdentifier::LIFECYCLE_STATUS);
471 $actions->disallowCustomInput(
$vocab);
473 $this->assertEmpty($standard_repo->changes_to_active);
474 $this->assertEmpty($controlled_repo->changes_to_active);
475 $this->assertEmpty($controlled_repo->changes_to_custom_input);
481 $this->getInfos(
false,
true,
true,
true),
482 $controlled_repo = $this->getControlledRepo(),
483 $standard_repo = $this->getStandardRepo(),
487 $actions->disallowCustomInput(
$vocab);
489 $this->assertEmpty($standard_repo->changes_to_active);
490 $this->assertEmpty($controlled_repo->changes_to_active);
491 $this->assertEmpty($controlled_repo->changes_to_custom_input);
497 $this->getInfos(
false,
true,
true,
false),
498 $controlled_repo = $this->getControlledRepo(),
499 $standard_repo = $this->getStandardRepo(),
502 $this->expectException(\ilMDVocabulariesException::class);
503 $actions->delete($this->getVocabulary(Type::STANDARD,
'some id'));
509 $this->getInfos(
false,
true,
true,
true),
510 $controlled_repo = $this->getControlledRepo(),
511 $standard_repo = $this->getStandardRepo(),
514 $actions->delete($this->getVocabulary(Type::STANDARD,
'some id'));
516 $this->assertEmpty($controlled_repo->exposed_deletions);
522 $this->getInfos(
true,
true,
true,
true),
523 $controlled_repo = $this->getControlledRepo(),
524 $standard_repo = $this->getStandardRepo(),
527 $actions->delete($this->getVocabulary(Type::CONTROLLED_STRING,
'some id'));
531 $controlled_repo->exposed_deletions
538 $this->getInfos(
true,
true,
true,
true),
539 $controlled_repo = $this->getControlledRepo(),
540 $standard_repo = $this->getStandardRepo(),
543 $actions->delete($this->getVocabulary(Type::CONTROLLED_VOCAB_VALUE,
'some id'));
547 $controlled_repo->exposed_deletions
554 $this->getInfos(
true,
true,
true,
true),
555 $controlled_repo = $this->getControlledRepo(),
556 $standard_repo = $this->getStandardRepo(),
561 $this->assertEmpty($controlled_repo->exposed_deletions);
$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