19declare(strict_types=1);
23use PHPUnit\Framework\TestCase;
53 int $editorial_ref_id = 0,
54 int $publishing_ref_id = 0,
55 bool $automatic_publishing_enabled =
false,
60 $automatic_publishing_enabled
63 protected
int $editorial_ref_id,
64 protected
int $publishing_ref_id,
65 protected bool $automatic_publishing_enabled
69 public function isAutomaticPublishingEnabled(): bool
71 return $this->automatic_publishing_enabled;
74 public function getContainerRefIDForEditorialStep():
int
76 return $this->editorial_ref_id;
79 public function getContainerRefIDForPublishing():
int
81 return $this->publishing_ref_id;
90 array $exclusive_ref_ids = [],
92 return new class ($exclusive_ref_ids) extends NullObjectHandler {
93 public array $exposed_ref_creations = [];
94 public array $exposed_ref_deletions = [];
97 protected array $exclusive_ref_ids
101 public function referenceObjectInTargetContainer(
int $obj_id,
int $container_ref_id):
int
103 $new_ref_id = (
int) ($container_ref_id . $obj_id);
104 $this->exposed_ref_creations[] = [
106 'container_ref_id' => $container_ref_id,
107 'new_ref_id' => $new_ref_id
112 public function isOnlyReference(
int $ref_id): bool
114 return in_array(
$ref_id, $this->exclusive_ref_ids);
117 public function deleteReference(
int $ref_id): void
119 $this->exposed_ref_deletions[] =
$ref_id;
125 int ...$already_have_export_obj_ids
127 return new class ($already_have_export_obj_ids) extends NullExportHandler {
128 public array $exposed_created_exports_obj_ids = [];
131 protected array $already_have_export_obj_ids
135 public function hasPublicAccessExport(
int $obj_id): bool
137 return in_array($obj_id, $this->already_have_export_obj_ids);
140 public function createPublicAccessExport(
int $obj_id): void
142 $this->exposed_created_exports_obj_ids[] = $obj_id;
151 array $currently_harvested = []
152 ): StatusRepository {
153 return new class ($currently_harvested) extends NullStatusRepository {
154 public array $exposed_blocks = [];
155 public array $exposed_deletions = [];
156 public array $exposed_creations = [];
159 protected array $currently_harvested
163 public function setHarvestingBlocked(
int $obj_id,
bool $blocked): void
165 $this->exposed_blocks[] = [
167 'blocked' => $blocked
171 public function getHarvestRefID(
int $obj_id):
int
173 return $this->currently_harvested[$obj_id];
176 public function deleteHarvestRefID(
int $obj_id): void
178 $this->exposed_deletions[] = $obj_id;
181 public function setHarvestRefID(
int $obj_id,
int $harvested_ref_id): void
183 $this->exposed_creations[] = [
185 'href_id' => $harvested_ref_id
192 int ...$has_record_obj_ids,
193 ): ExposedRecordRepository {
194 return new class ($has_record_obj_ids) extends NullExposedRecordRepository {
195 public array $exposed_deletions = [];
196 public array $exposed_updates = [];
197 public array $exposed_creations = [];
200 protected array $has_record_obj_ids
204 public function doesRecordExistForObjID(
int $obj_id): bool
206 return in_array($obj_id, $this->has_record_obj_ids);
209 public function updateRecord(
int $obj_id,
bool $is_deleted, ?\DOMDocument $metadata): void
211 $this->exposed_updates[] = [
213 'deleted' => $is_deleted,
214 'metadata' => $metadata?->saveXML()
218 public function createRecord(
int $obj_id,
string $identifier, \DOMDocument $metadata): void
220 $this->exposed_creations[] = [
222 'identifier' => $identifier,
223 'metadata' => $metadata->saveXML()
232 protected function getXMLWriter(array $returned_md = []): SimpleDCXMLWriter
234 return new class ($returned_md) extends
NullWriter {
235 public array $exposed_params = [];
237 public function __construct(
protected array $returned_md)
241 public function writeSimpleDCMetaData(
int $obj_id,
int $ref_id,
string $type): \DOMDocument
243 $this->exposed_params[] = [
249 $xml = new \DOMDocument();
250 $xml->loadXML($this->returned_md[$obj_id]);
258 return $this->createMock(\ilAccess::class);
264 $this->getExposedRecordRepository(),
265 $status_repo = $this->getStatusRepository(),
266 $this->getObjectHandler(),
267 $this->getExportHandler(),
268 $this->getSettings(),
269 $this->getXMLWriter(),
270 $this->getNullAccess()
273 $publisher->block(123);
280 $status_repo->exposed_blocks
287 $this->getExposedRecordRepository(),
288 $status_repo = $this->getStatusRepository(),
289 $this->getObjectHandler(),
290 $this->getExportHandler(),
291 $this->getSettings(),
292 $this->getXMLWriter(),
293 $this->getNullAccess()
296 $publisher->unblock(123);
298 $this->assertSame([[
'obj_id' => 123,
'blocked' =>
false]], $status_repo->exposed_blocks);
309 $exposed_repo = $this->getExposedRecordRepository(),
310 $status_repo = $this->getStatusRepository(),
311 $object_handler = $this->getObjectHandler(),
312 $export_handler = $this->getExportHandler(),
313 $this->getSettings(0, 456),
314 $this->getXMLWriter([123 => $md]),
315 $this->getNullAccess()
318 $publisher->publish(123,
'type');
323 'container_ref_id' => 456,
324 'new_ref_id' => 456123
326 $object_handler->exposed_ref_creations
333 $status_repo->exposed_creations
337 $export_handler->exposed_created_exports_obj_ids
342 'identifier' =>
'il__type_123',
345 $exposed_repo->exposed_creations
357 $exposed_repo = $this->getExposedRecordRepository(),
358 $status_repo = $this->getStatusRepository(),
359 $object_handler = $this->getObjectHandler(),
360 $export_handler = $this->getExportHandler(123),
361 $this->getSettings(0, 456),
362 $this->getXMLWriter([123 => $md]),
363 $this->getNullAccess()
366 $publisher->publish(123,
'type');
371 'container_ref_id' => 456,
372 'new_ref_id' => 456123
374 $object_handler->exposed_ref_creations
381 $status_repo->exposed_creations
383 $this->assertEmpty($export_handler->exposed_created_exports_obj_ids);
387 'identifier' =>
'il__type_123',
390 $exposed_repo->exposed_creations
402 $exposed_repo = $this->getExposedRecordRepository(123),
403 $status_repo = $this->getStatusRepository(),
404 $object_handler = $this->getObjectHandler(),
405 $export_handler = $this->getExportHandler(),
406 $this->getSettings(0, 456),
407 $this->getXMLWriter([123 => $md]),
408 $this->getNullAccess()
411 $publisher->publish(123,
'type');
416 'container_ref_id' => 456,
417 'new_ref_id' => 456123
419 $object_handler->exposed_ref_creations
426 $status_repo->exposed_creations
430 $export_handler->exposed_created_exports_obj_ids
438 $exposed_repo->exposed_updates
445 $exposed_repo = $this->getExposedRecordRepository(),
446 $status_repo = $this->getStatusRepository([123 => 456123]),
447 $object_handler = $this->getObjectHandler(),
448 $this->getExportHandler(),
449 $this->getSettings(),
450 $this->getXMLWriter(),
451 $this->getNullAccess()
454 $publisher->withdraw(123);
458 $object_handler->exposed_ref_deletions
462 $status_repo->exposed_deletions
470 $exposed_repo->exposed_updates
472 $this->assertEmpty($status_repo->exposed_blocks);
478 $exposed_repo = $this->getExposedRecordRepository(),
479 $status_repo = $this->getStatusRepository([123 => 456123]),
480 $object_handler = $this->getObjectHandler([456123]),
481 $this->getExportHandler(),
482 $this->getSettings(),
483 $this->getXMLWriter(),
484 $this->getNullAccess()
487 $publisher->withdraw(123);
489 $this->assertEmpty($object_handler->exposed_ref_deletions);
492 $status_repo->exposed_deletions
500 $exposed_repo->exposed_updates
502 $this->assertEmpty($status_repo->exposed_blocks);
508 $exposed_repo = $this->getExposedRecordRepository(),
509 $status_repo = $this->getStatusRepository([123 => 456123]),
510 $object_handler = $this->getObjectHandler(),
511 $this->getExportHandler(),
512 $this->getSettings(0, 0,
true),
513 $this->getXMLWriter(),
514 $this->getNullAccess()
517 $publisher->withdraw(123);
521 $object_handler->exposed_ref_deletions
525 $status_repo->exposed_deletions
533 $exposed_repo->exposed_updates
540 $status_repo->exposed_blocks
547 $this->getExposedRecordRepository(),
548 $status_repo = $this->getStatusRepository(),
549 $object_handler = $this->getObjectHandler(),
550 $export_handler = $this->getExportHandler(),
551 $this->getSettings(456),
552 $this->getXMLWriter(),
553 $this->getNullAccess()
556 $publisher->submit(123);
561 'container_ref_id' => 456,
562 'new_ref_id' => 456123
564 $object_handler->exposed_ref_creations
571 $status_repo->exposed_creations
575 $export_handler->exposed_created_exports_obj_ids
582 $this->getExposedRecordRepository(),
583 $status_repo = $this->getStatusRepository(),
584 $object_handler = $this->getObjectHandler(),
585 $export_handler = $this->getExportHandler(123),
586 $this->getSettings(456),
587 $this->getXMLWriter(),
588 $this->getNullAccess()
591 $publisher->submit(123);
596 'container_ref_id' => 456,
597 'new_ref_id' => 456123
599 $object_handler->exposed_ref_creations
606 $status_repo->exposed_creations
608 $this->assertEmpty($export_handler->exposed_created_exports_obj_ids);
619 $exposed_repo = $this->getExposedRecordRepository(),
620 $status_repo = $this->getStatusRepository([123 => 456123]),
621 $object_handler = $this->getObjectHandler(),
622 $this->getExportHandler(),
623 $this->getSettings(456, 789),
624 $this->getXMLWriter([123 => $md]),
625 $this->getNullAccess()
628 $publisher->accept(123,
'type');
633 'container_ref_id' => 789,
634 'new_ref_id' => 789123
636 $object_handler->exposed_ref_creations
640 $object_handler->exposed_ref_deletions
647 $status_repo->exposed_creations
652 'identifier' =>
'il__type_123',
655 $exposed_repo->exposed_creations
667 $exposed_repo = $this->getExposedRecordRepository(123),
668 $status_repo = $this->getStatusRepository([123 => 456123]),
669 $object_handler = $this->getObjectHandler(),
670 $this->getExportHandler(),
671 $this->getSettings(456, 789),
672 $this->getXMLWriter([123 => $md]),
673 $this->getNullAccess()
676 $publisher->accept(123,
'type');
681 'container_ref_id' => 789,
682 'new_ref_id' => 789123
684 $object_handler->exposed_ref_creations
688 $object_handler->exposed_ref_deletions
695 $status_repo->exposed_creations
703 $exposed_repo->exposed_updates
710 $this->getExposedRecordRepository(),
711 $status_repo = $this->getStatusRepository([123 => 456123]),
712 $object_handler = $this->getObjectHandler(),
713 $this->getExportHandler(),
714 $this->getSettings(),
715 $this->getXMLWriter(),
716 $this->getNullAccess()
719 $publisher->reject(123);
723 $object_handler->exposed_ref_deletions
727 $status_repo->exposed_deletions
729 $this->assertEmpty($status_repo->exposed_blocks);
735 $this->getExposedRecordRepository(),
736 $status_repo = $this->getStatusRepository([123 => 456123]),
737 $object_handler = $this->getObjectHandler([456123]),
738 $this->getExportHandler(),
739 $this->getSettings(),
740 $this->getXMLWriter(),
741 $this->getNullAccess()
744 $publisher->reject(123);
746 $this->assertEmpty($object_handler->exposed_ref_deletions);
749 $status_repo->exposed_deletions
751 $this->assertEmpty($status_repo->exposed_blocks);
757 $this->getExposedRecordRepository(),
758 $status_repo = $this->getStatusRepository([123 => 456123]),
759 $object_handler = $this->getObjectHandler(),
760 $this->getExportHandler(),
761 $this->getSettings(0, 0,
true),
762 $this->getXMLWriter(),
763 $this->getNullAccess()
766 $publisher->reject(123);
770 $object_handler->exposed_ref_deletions
774 $status_repo->exposed_deletions
781 $status_repo->exposed_blocks
__construct()
Constructor setup ILIAS global object @access public.
Class ilAccessHandler Checks access for ILIAS objects.
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