ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ILIAS\MetaData\OERHarvester\CronJob\AutomaticPublisherTest Class Reference
+ Inheritance diagram for ILIAS\MetaData\OERHarvester\CronJob\AutomaticPublisherTest:
+ Collaboration diagram for ILIAS\MetaData\OERHarvester\CronJob\AutomaticPublisherTest:

Public Member Functions

 testRunWithdrawDeprecatedReferenceIncorrectTypeOrCopyright ()
 
 testRunWithdrawDeprecatedReferenceBlocked ()
 
 testRunWithdrawDeprecatedReferenceObjectDeleted ()
 
 testRunWithdrawDeprecatedReferenceReferenceDeleted ()
 
 testRunWithdrawDeprecatedReferenceContinueDespiteError ()
 
 testRunPublishObject ()
 
 testRunSubmitObject ()
 
 testRunDoNotPublishIfNoAutomaticPublishing ()
 
 testRunDoNotPublishBlockedObject ()
 
 testRunDoNotHarvestDeletedObject ()
 
 testRunDoNotPublishAlreadyPublishedObject ()
 
 testRunPublishObjectContinueDespiteError ()
 
 testRunUpdateExposedRecord ()
 
 testRunUpdateExposedRecordMarkedAsDeleted ()
 
 testRunDoNotUpdateNotHarvestedExposedRecordMarkedAsDeleted ()
 
 testRunWithUnforeseenError ()
 

Protected Member Functions

 getPublisher (?int $throw_error_on_withdraw_obj_id=null, ?int $throw_error_on_publish_obj_id=null)
 
 getSettings (bool $automatic_publishing_enabled=false, bool $editorial_step_enabled=false, array $types=[], array $copyright_ids=[], int $publishing_container_ref_id=0)
 
 getObjectHandler (array $deleted_obj_ids=[], int $valid_publishing_container=0, array $ref_ids_in_container=[], array $deleted_ref_ids=[])
 
 getStatusRepository (array $currently_harvested=[], array $blocked_obj_ids=[], bool $throw_error=false)
 Currently harvested objects are passed as obj_id => href_id. More...
 
 getExposedRecordRepository (array $returned_records=[], array $deleted_records=[])
 Records are passed as array via obj_id => metadata-xml as string. More...
 
 getSearchFactory (int ... $search_result_obj_ids)
 
 getXMLWriter (array $returned_md=[])
 Metadata is passed as array via obj_id => metadata-xml as string. More...
 
 getNullLogger ()
 
 getCronResultWrapper ()
 

Detailed Description

Definition at line 50 of file AutomaticPublisherTest.php.

Member Function Documentation

◆ getCronResultWrapper()

ILIAS\MetaData\OERHarvester\CronJob\AutomaticPublisherTest::getCronResultWrapper ( )
protected

Definition at line 406 of file AutomaticPublisherTest.php.

406 : WrapperInterface
407 {
408 return new class () extends NullWrapper {
409 public int $exposed_status;
410 public string $exposed_message;
411
412 public function withMessage(string $message): WrapperInterface
413 {
414 $clone = clone $this;
415 $clone->exposed_message = $message;
416 return $clone;
417 }
418
419 public function withStatus(int $status): WrapperInterface
420 {
421 $clone = clone $this;
422 $clone->exposed_status = $status;
423 return $clone;
424 }
425 };
426 }

◆ getExposedRecordRepository()

ILIAS\MetaData\OERHarvester\CronJob\AutomaticPublisherTest::getExposedRecordRepository ( array  $returned_records = [],
array  $deleted_records = [] 
)
protected

Records are passed as array via obj_id => metadata-xml as string.

Records supposed to be marked as deleted are as their obj_id to the second argument.

Definition at line 233 of file AutomaticPublisherTest.php.

236 : ExposedRecordRepository {
237 return new class ($returned_records, $deleted_records) extends NullExposedRecordRepository {
238 public array $exposed_deletions = [];
239 public array $exposed_updates = [];
240
241 public function __construct(
242 protected array $returned_records,
243 protected array $deleted_records
244 ) {
245 }
246
247 public function getRecords(
248 ?\DateTimeImmutable $from = null,
249 ?\DateTimeImmutable $until = null,
250 ?int $limit = null,
251 ?int $offset = null
252 ): \Generator {
253 foreach ($this->returned_records as $obj_id => $metadata) {
254 $is_deleted = in_array($obj_id, $this->deleted_records);
255 yield new class ($obj_id, $is_deleted, $metadata) extends NullRecord {
256 public function __construct(
257 protected int $obj_id,
258 protected bool $is_deleted,
259 protected ?string $metadata
260 ) {
261 }
262
263 public function infos(): RecordInfosInterface
264 {
265 return new class ($this->obj_id, $this->is_deleted) extends NullRecordInfos {
266 public function __construct(
267 protected int $obj_id,
268 protected bool $is_deleted
269 ) {
270 }
271
272 public function objID(): int
273 {
274 return $this->obj_id;
275 }
276
277 public function isDeleted(): bool
278 {
279 return $this->is_deleted;
280 }
281 };
282 }
283
284 public function metadata(): ?\DOMDocument
285 {
286 if ($this->metadata === null) {
287 return null;
288 }
289 $xml = new \DOMDocument();
290 $xml->loadXML($this->metadata);
291 return $xml;
292 }
293 };
294 }
295 }
296
297 public function deleteRecordsMarkedAsDeletedOlderThan(\DateInterval $interval): void
298 {
299 $this->exposed_deletions[] = ['interval' => $interval];
300 }
301
302 public function updateRecord(int $obj_id, bool $is_deleted, ?\DOMDocument $metadata): void
303 {
304 $this->exposed_updates[] = [
305 'obj_id' => $obj_id,
306 'deleted' => $is_deleted,
307 'metadata' => $metadata?->saveXML()
308 ];
309 }
310 };
311 }
__construct()
Constructor setup ILIAS global object @access public.
Definition: class.ilias.php:76

◆ getNullLogger()

ILIAS\MetaData\OERHarvester\CronJob\AutomaticPublisherTest::getNullLogger ( )
protected

Definition at line 401 of file AutomaticPublisherTest.php.

401 : \ilLogger
402 {
403 return $this->createMock(\ilLogger::class);
404 }
Component logger with individual log levels by component id.

◆ getObjectHandler()

ILIAS\MetaData\OERHarvester\CronJob\AutomaticPublisherTest::getObjectHandler ( array  $deleted_obj_ids = [],
int  $valid_publishing_container = 0,
array  $ref_ids_in_container = [],
array  $deleted_ref_ids = [] 
)
protected

Definition at line 143 of file AutomaticPublisherTest.php.

148 : ObjectHandler {
149 return new class (
150 $deleted_obj_ids,
151 $valid_publishing_container,
152 $ref_ids_in_container,
153 $deleted_ref_ids
154 ) extends NullObjectHandler {
155 public function __construct(
156 protected array $deleted_obj_ids,
157 protected int $valid_publishing_container,
158 protected array $ref_ids_in_container,
159 protected array $deleted_ref_ids
160 ) {
161 }
162
163 public function doesReferenceExist(int $ref_id): bool
164 {
165 return !in_array($ref_id, $this->deleted_ref_ids);
166 }
167
168 public function isObjectDeleted(int $obj_id): bool
169 {
170 return in_array($obj_id, $this->deleted_obj_ids);
171 }
172
173 public function isReferenceInContainer(int $ref_id, int $container_ref_id): bool
174 {
175 if ($container_ref_id !== $this->valid_publishing_container) {
176 return false;
177 }
178 return in_array($ref_id, $this->ref_ids_in_container);
179 }
180
181 public function getTypeOfObject(int $obj_id): string
182 {
183 return 'type_' . $obj_id;
184 }
185 };
186 }
$ref_id
Definition: ltiauth.php:66

◆ getPublisher()

ILIAS\MetaData\OERHarvester\CronJob\AutomaticPublisherTest::getPublisher ( ?int  $throw_error_on_withdraw_obj_id = null,
?int  $throw_error_on_publish_obj_id = null 
)
protected

Definition at line 52 of file AutomaticPublisherTest.php.

55 : PublisherInterface {
56 return new class (
57 $throw_error_on_withdraw_obj_id,
58 $throw_error_on_publish_obj_id
59 ) extends NullPublisher {
60 public array $exposed_withdrawn_objects = [];
61 public array $exposed_submitted_objects = [];
62 public array $exposed_published_objects = [];
63
64 public function __construct(
65 protected ?int $throw_error_on_withdraw_obj_id,
66 protected ?int $throw_error_on_publish_obj_id
67 ) {
68 }
69
70 public function withdraw(int $obj_id): void
71 {
72 if ($this->throw_error_on_withdraw_obj_id === $obj_id) {
73 throw new \ilMDOERHarvesterException('error');
74 }
75 $this->exposed_withdrawn_objects[] = $obj_id;
76 }
77
78 public function submit(int $obj_id): void
79 {
80 $this->exposed_submitted_objects[] = $obj_id;
81 }
82
83 public function publish(int $obj_id, string $type): void
84 {
85 if ($this->throw_error_on_publish_obj_id === $obj_id) {
86 throw new \ilMDOERHarvesterException('error');
87 }
88 $this->exposed_published_objects[] = [$obj_id, $type];
89 }
90 };
91 }

◆ getSearchFactory()

ILIAS\MetaData\OERHarvester\CronJob\AutomaticPublisherTest::getSearchFactory ( int ...  $search_result_obj_ids)
protected

Definition at line 313 of file AutomaticPublisherTest.php.

313 : SearchFactory
314 {
315 return new class ($search_result_obj_ids) extends NullFactory {
316 public array $exposed_search_params;
317
318 public function __construct(public array $search_result_obj_ids)
319 {
320 }
321
322 public function get(): SearcherInterface
323 {
324 return new class ($this) extends NullSearcher {
325 protected array $types = [];
326 protected bool $restricted_to_repository = false;
327
328 public function __construct(protected SearchFactory $factory)
329 {
330 }
331
332 public function withRestrictionToRepositoryObjects(bool $restricted): SearcherInterface
333 {
334 $clone = clone $this;
335 $clone->restricted_to_repository = $restricted;
336 return $clone;
337 }
338
339 public function withAdditionalTypeFilter(string $type): SearcherInterface
340 {
341 $clone = clone $this;
342 $clone->types[] = $type;
343 return $clone;
344 }
345
346 public function search(
347 LOMRepository $lom_repository,
348 int $first_entry_id,
349 int ...$further_entry_ids
350 ): \Generator {
351 $this->factory->exposed_search_params[] = [
352 'restricted' => $this->restricted_to_repository,
353 'types' => $this->types,
354 'entries' => [$first_entry_id, ...$further_entry_ids]
355 ];
356 foreach ($this->factory->search_result_obj_ids as $obj_id) {
357 yield new class ($obj_id) extends NullRessourceID {
358 public function __construct(protected int $obj_id)
359 {
360 }
361
362 public function objID(): int
363 {
364 return $this->obj_id;
365 }
366 };
367 }
368 }
369 };
370 }
371 };
372 }
factory()

References ILIAS\GlobalScreen\Provider\__construct(), factory(), and ILIAS\UI\examples\Symbol\Glyph\Search\search().

+ Here is the call graph for this function:

◆ getSettings()

ILIAS\MetaData\OERHarvester\CronJob\AutomaticPublisherTest::getSettings ( bool  $automatic_publishing_enabled = false,
bool  $editorial_step_enabled = false,
array  $types = [],
array  $copyright_ids = [],
int  $publishing_container_ref_id = 0 
)
protected

Definition at line 93 of file AutomaticPublisherTest.php.

99 : SettingsInterface {
100 return new class (
101 $automatic_publishing_enabled,
102 $editorial_step_enabled,
103 $types,
104 $copyright_ids,
105 $publishing_container_ref_id
106 ) extends NullSettings {
107 public function __construct(
108 protected bool $automatic_publishing_enabled,
109 protected bool $editorial_step_enabled,
110 protected array $types,
111 protected array $copyright_ids,
112 protected int $publishing_container_ref_id
113 ) {
114 }
115
116 public function isAutomaticPublishingEnabled(): bool
117 {
118 return $this->automatic_publishing_enabled;
119 }
120
121 public function isEditorialStepEnabled(): bool
122 {
123 return $this->editorial_step_enabled;
124 }
125
126 public function getObjectTypesSelectedForPublishing(): array
127 {
128 return $this->types;
129 }
130
131 public function getCopyrightEntryIDsSelectedForPublishing(): array
132 {
133 return $this->copyright_ids;
134 }
135
136 public function getContainerRefIDForPublishing(): int
137 {
138 return $this->publishing_container_ref_id;
139 }
140 };
141 }

◆ getStatusRepository()

ILIAS\MetaData\OERHarvester\CronJob\AutomaticPublisherTest::getStatusRepository ( array  $currently_harvested = [],
array  $blocked_obj_ids = [],
bool  $throw_error = false 
)
protected

Currently harvested objects are passed as obj_id => href_id.

Definition at line 191 of file AutomaticPublisherTest.php.

195 : StatusRepository {
196 return new class ($currently_harvested, $blocked_obj_ids, $throw_error) extends NullStatusRepository {
197 public function __construct(
198 protected array $currently_harvested,
199 protected array $blocked_obj_ids,
200 protected bool $throw_error
201 ) {
202 }
203
204 public function getAllHarvestedObjIDs(): \Generator
205 {
206 if ($this->throw_error === true) {
207 throw new \ilMDOERHarvesterException('error');
208 }
209 yield from array_keys($this->currently_harvested);
210 }
211
212 public function filterOutBlockedObjects(int ...$obj_ids): \Generator
213 {
214 foreach ($obj_ids as $obj_id) {
215 if (!in_array($obj_id, $this->blocked_obj_ids)) {
216 yield $obj_id;
217 }
218 }
219 }
220
221 public function getHarvestRefID(int $obj_id): int
222 {
223 return $this->currently_harvested[$obj_id] ?? 0;
224 }
225 };
226 }

◆ getXMLWriter()

ILIAS\MetaData\OERHarvester\CronJob\AutomaticPublisherTest::getXMLWriter ( array  $returned_md = [])
protected

Metadata is passed as array via obj_id => metadata-xml as string.

Definition at line 377 of file AutomaticPublisherTest.php.

377 : SimpleDCXMLWriter
378 {
379 return new class ($returned_md) extends NullWriter {
380 public array $exposed_params = [];
381
382 public function __construct(protected array $returned_md)
383 {
384 }
385
386 public function writeSimpleDCMetaData(int $obj_id, int $ref_id, string $type): \DOMDocument
387 {
388 $this->exposed_params[] = [
389 'obj_id' => $obj_id,
390 'ref_id' => $ref_id,
391 'type' => $type
392 ];
393
394 $xml = new \DOMDocument();
395 $xml->loadXML($this->returned_md[$obj_id]);
396 return $xml;
397 }
398 };
399 }

References $ref_id, and ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

◆ testRunDoNotHarvestDeletedObject()

ILIAS\MetaData\OERHarvester\CronJob\AutomaticPublisherTest::testRunDoNotHarvestDeletedObject ( )

Definition at line 676 of file AutomaticPublisherTest.php.

676 : void
677 {
678 $harvester = new AutomaticPublisher(
679 $publisher = $this->getPublisher(),
680 $this->getSettings(true, false, ['type', 'second type'], [12, 5], 123),
681 $this->getObjectHandler([45]),
682 $this->getStatusRepository([32 => 12332]),
684 $this->getSearchFactory(32, 45),
685 new NullLOMRepository(),
686 $this->getXMLWriter(),
687 $this->getNullLogger()
688 );
689
690 $result = $harvester->run($this->getCronResultWrapper());
691
692 $this->assertSame(JobResult::STATUS_NO_ACTION, $result->exposed_status);
693 $this->assertSame(
694 'Withdrew 0 deprecated objects.<br>' .
695 'Updated 0 published objects.<br>' .
696 'Published or submitted for review 0 new objects.',
697 $result->exposed_message
698 );
699 $this->assertEmpty($publisher->exposed_published_objects);
700 }
final const int STATUS_NO_ACTION
Definition: JobResult.php:26
getObjectHandler(array $deleted_obj_ids=[], int $valid_publishing_container=0, array $ref_ids_in_container=[], array $deleted_ref_ids=[])
getExposedRecordRepository(array $returned_records=[], array $deleted_records=[])
Records are passed as array via obj_id => metadata-xml as string.
getStatusRepository(array $currently_harvested=[], array $blocked_obj_ids=[], bool $throw_error=false)
Currently harvested objects are passed as obj_id => href_id.
getSettings(bool $automatic_publishing_enabled=false, bool $editorial_step_enabled=false, array $types=[], array $copyright_ids=[], int $publishing_container_ref_id=0)
getPublisher(?int $throw_error_on_withdraw_obj_id=null, ?int $throw_error_on_publish_obj_id=null)
getXMLWriter(array $returned_md=[])
Metadata is passed as array via obj_id => metadata-xml as string.

◆ testRunDoNotPublishAlreadyPublishedObject()

ILIAS\MetaData\OERHarvester\CronJob\AutomaticPublisherTest::testRunDoNotPublishAlreadyPublishedObject ( )

Definition at line 702 of file AutomaticPublisherTest.php.

702 : void
703 {
704 $harvester = new AutomaticPublisher(
705 $publisher = $this->getPublisher(),
706 $this->getSettings(true, false, ['type', 'second type'], [12, 5], 123),
707 $this->getObjectHandler(),
708 $this->getStatusRepository([32 => 12332, 45 => 12345]),
710 $this->getSearchFactory(32, 45),
711 new NullLOMRepository(),
712 $this->getXMLWriter(),
713 $this->getNullLogger()
714 );
715
716 $result = $harvester->run($this->getCronResultWrapper());
717
718 $this->assertSame(JobResult::STATUS_NO_ACTION, $result->exposed_status);
719 $this->assertSame(
720 'Withdrew 0 deprecated objects.<br>' .
721 'Updated 0 published objects.<br>' .
722 'Published or submitted for review 0 new objects.',
723 $result->exposed_message
724 );
725 $this->assertEmpty($publisher->exposed_published_objects);
726 }

◆ testRunDoNotPublishBlockedObject()

ILIAS\MetaData\OERHarvester\CronJob\AutomaticPublisherTest::testRunDoNotPublishBlockedObject ( )

Definition at line 650 of file AutomaticPublisherTest.php.

650 : void
651 {
652 $harvester = new AutomaticPublisher(
653 $publisher = $this->getPublisher(),
654 $this->getSettings(true, false, ['type', 'second type'], [12, 5], 123),
655 $this->getObjectHandler(),
656 $this->getStatusRepository([32 => 12332], [45]),
658 $this->getSearchFactory(32, 45),
659 new NullLOMRepository(),
660 $this->getXMLWriter(),
661 $this->getNullLogger()
662 );
663
664 $result = $harvester->run($this->getCronResultWrapper());
665
666 $this->assertSame(JobResult::STATUS_NO_ACTION, $result->exposed_status);
667 $this->assertSame(
668 'Withdrew 0 deprecated objects.<br>' .
669 'Updated 0 published objects.<br>' .
670 'Published or submitted for review 0 new objects.',
671 $result->exposed_message
672 );
673 $this->assertEmpty($publisher->exposed_published_objects);
674 }

◆ testRunDoNotPublishIfNoAutomaticPublishing()

ILIAS\MetaData\OERHarvester\CronJob\AutomaticPublisherTest::testRunDoNotPublishIfNoAutomaticPublishing ( )

Definition at line 625 of file AutomaticPublisherTest.php.

625 : void
626 {
627 $harvester = new AutomaticPublisher(
628 $publisher = $this->getPublisher(),
629 $this->getSettings(false, false, ['type', 'second type'], [12, 5], 123),
630 $this->getObjectHandler(),
631 $this->getStatusRepository([32 => 12332]),
633 $this->getSearchFactory(32, 45),
634 new NullLOMRepository(),
635 $this->getXMLWriter(),
636 $this->getNullLogger()
637 );
638
639 $result = $harvester->run($this->getCronResultWrapper());
640
641 $this->assertSame(JobResult::STATUS_NO_ACTION, $result->exposed_status);
642 $this->assertSame(
643 'Withdrew 0 deprecated objects.<br>' .
644 'Updated 0 published objects.',
645 $result->exposed_message
646 );
647 $this->assertEmpty($publisher->exposed_published_objects);
648 }

◆ testRunDoNotUpdateNotHarvestedExposedRecordMarkedAsDeleted()

ILIAS\MetaData\OERHarvester\CronJob\AutomaticPublisherTest::testRunDoNotUpdateNotHarvestedExposedRecordMarkedAsDeleted ( )

Definition at line 835 of file AutomaticPublisherTest.php.

835 : void
836 {
837 $harvester = new AutomaticPublisher(
838 $this->getPublisher(),
839 $this->getSettings(false, false, ['type', 'second type'], [12, 5], 123),
840 $this->getObjectHandler([], 123, [12332]),
841 $this->getStatusRepository([32 => 12332]),
842 $record_repo = $this->getExposedRecordRepository([32 => '<el>32</el>', 45 => null], [45]),
843 $this->getSearchFactory(32),
844 new NullLOMRepository(),
845 $this->getXMLWriter([32 => '<el>32</el>', 45 => '<el>45 changed</el>']),
846 $this->getNullLogger()
847 );
848
849 $result = $harvester->run($this->getCronResultWrapper());
850
851 $this->assertSame(JobResult::STATUS_NO_ACTION, $result->exposed_status);
852 $this->assertSame(
853 'Withdrew 0 deprecated objects.<br>' .
854 'Updated 0 published objects.',
855 $result->exposed_message
856 );
857 $this->assertEmpty($record_repo->exposed_updates);
858 $this->assertCount(1, $record_repo->exposed_deletions);
859 }

◆ testRunPublishObject()

ILIAS\MetaData\OERHarvester\CronJob\AutomaticPublisherTest::testRunPublishObject ( )

Definition at line 557 of file AutomaticPublisherTest.php.

557 : void
558 {
559 $harvester = new AutomaticPublisher(
560 $publisher = $this->getPublisher(),
561 $this->getSettings(true, false, ['type', 'second type'], [12, 5], 123),
562 $this->getObjectHandler(),
563 $this->getStatusRepository([32 => 12332]),
565 $search_factory = $this->getSearchFactory(32, 45),
566 new NullLOMRepository(),
567 $this->getXMLWriter(),
568 $this->getNullLogger()
569 );
570
571 $result = $harvester->run($this->getCronResultWrapper());
572
573 $this->assertSame(JobResult::STATUS_OK, $result->exposed_status);
574 $this->assertSame(
575 'Withdrew 0 deprecated objects.<br>' .
576 'Updated 0 published objects.<br>' .
577 'Published or submitted for review 1 new objects.',
578 $result->exposed_message
579 );
580 $this->assertSame(
581 [[
582 'restricted' => true,
583 'types' => ['type', 'second type'],
584 'entries' => [12, 5]
585 ]],
586 $search_factory->exposed_search_params
587 );
588 $this->assertSame([[45, 'type_45']], $publisher->exposed_published_objects);
589 }
final const int STATUS_OK
Definition: JobResult.php:27

◆ testRunPublishObjectContinueDespiteError()

ILIAS\MetaData\OERHarvester\CronJob\AutomaticPublisherTest::testRunPublishObjectContinueDespiteError ( )

Definition at line 728 of file AutomaticPublisherTest.php.

728 : void
729 {
730 $harvester = new AutomaticPublisher(
731 $publisher = $this->getPublisher(null, 45),
732 $this->getSettings(true, false, ['type', 'second type'], [12, 5], 123),
733 $this->getObjectHandler(),
734 $this->getStatusRepository(),
736 $this->getSearchFactory(32, 45, 67),
737 new NullLOMRepository(),
738 $this->getXMLWriter(),
739 $this->getNullLogger()
740 );
741
742 $result = $harvester->run($this->getCronResultWrapper());
743
744 $this->assertSame(JobResult::STATUS_OK, $result->exposed_status);
745 $this->assertSame(
746 'Withdrew 0 deprecated objects.<br>' .
747 'Updated 0 published objects.<br>' .
748 'Published or submitted for review 2 new objects.',
749 $result->exposed_message
750 );
751 $this->assertSame([
752 [32, 'type_32'],
753 [67, 'type_67']
754 ], $publisher->exposed_published_objects);
755 }

◆ testRunSubmitObject()

ILIAS\MetaData\OERHarvester\CronJob\AutomaticPublisherTest::testRunSubmitObject ( )

Definition at line 591 of file AutomaticPublisherTest.php.

591 : void
592 {
593 $harvester = new AutomaticPublisher(
594 $publisher = $this->getPublisher(),
595 $this->getSettings(true, true, ['type', 'second type'], [12, 5], 123),
596 $this->getObjectHandler(),
597 $this->getStatusRepository([32 => 12332]),
599 $search_factory = $this->getSearchFactory(32, 45),
600 new NullLOMRepository(),
601 $this->getXMLWriter(),
602 $this->getNullLogger()
603 );
604
605 $result = $harvester->run($this->getCronResultWrapper());
606
607 $this->assertSame(JobResult::STATUS_OK, $result->exposed_status);
608 $this->assertSame(
609 'Withdrew 0 deprecated objects.<br>' .
610 'Updated 0 published objects.<br>' .
611 'Published or submitted for review 1 new objects.',
612 $result->exposed_message
613 );
614 $this->assertSame(
615 [[
616 'restricted' => true,
617 'types' => ['type', 'second type'],
618 'entries' => [12, 5]
619 ]],
620 $search_factory->exposed_search_params
621 );
622 $this->assertSame([45], $publisher->exposed_submitted_objects);
623 }

◆ testRunUpdateExposedRecord()

ILIAS\MetaData\OERHarvester\CronJob\AutomaticPublisherTest::testRunUpdateExposedRecord ( )

Definition at line 757 of file AutomaticPublisherTest.php.

757 : void
758 {
759 $harvester = new AutomaticPublisher(
760 $this->getPublisher(),
761 $this->getSettings(false, false, ['type', 'second type'], [12, 5], 123),
762 $this->getObjectHandler([], 123, [12332, 12345]),
763 $this->getStatusRepository([32 => 12332, 45 => 12345]),
764 $record_repo = $this->getExposedRecordRepository([32 => '<el>32</el>', 45 => '<el>45</el>']),
765 $this->getSearchFactory(32, 45),
766 new NullLOMRepository(),
767 $writer = $this->getXMLWriter([32 => '<el>32</el>', 45 => '<el>45 changed</el>']),
768 $this->getNullLogger()
769 );
770
771 $result = $harvester->run($this->getCronResultWrapper());
772
773 $this->assertSame(JobResult::STATUS_OK, $result->exposed_status);
774 $this->assertSame(
775 'Withdrew 0 deprecated objects.<br>' .
776 'Updated 1 published objects.',
777 $result->exposed_message
778 );
779 $this->assertCount(1, $record_repo->exposed_updates);
780 $this->assertSame(45, $record_repo->exposed_updates[0]['obj_id']);
781 $this->assertSame(false, $record_repo->exposed_updates[0]['deleted']);
782 $this->assertXmlStringEqualsXmlString(
783 '<el>45 changed</el>',
784 $record_repo->exposed_updates[0]['metadata']
785 );
786 $this->assertEquals(
787 [
788 ['obj_id' => 32, 'ref_id' => 12332, 'type' => 'type_32'],
789 ['obj_id' => 45, 'ref_id' => 12345, 'type' => 'type_45']
790 ],
791 $writer->exposed_params
792 );
793 $this->assertCount(1, $record_repo->exposed_deletions);
794 }

◆ testRunUpdateExposedRecordMarkedAsDeleted()

ILIAS\MetaData\OERHarvester\CronJob\AutomaticPublisherTest::testRunUpdateExposedRecordMarkedAsDeleted ( )

Definition at line 796 of file AutomaticPublisherTest.php.

796 : void
797 {
798 $harvester = new AutomaticPublisher(
799 $this->getPublisher(),
800 $this->getSettings(false, false, ['type', 'second type'], [12, 5], 123),
801 $this->getObjectHandler([], 123, [12332, 12345]),
802 $this->getStatusRepository([32 => 12332, 45 => 12345]),
803 $record_repo = $this->getExposedRecordRepository([32 => '<el>32</el>', 45 => null], [45]),
804 $this->getSearchFactory(32, 45),
805 new NullLOMRepository(),
806 $writer = $this->getXMLWriter([32 => '<el>32</el>', 45 => '<el>45 changed</el>']),
807 $this->getNullLogger()
808 );
809
810 $result = $harvester->run($this->getCronResultWrapper());
811
812 $this->assertSame(JobResult::STATUS_OK, $result->exposed_status);
813 $this->assertSame(
814 'Withdrew 0 deprecated objects.<br>' .
815 'Updated 1 published objects.',
816 $result->exposed_message
817 );
818 $this->assertCount(1, $record_repo->exposed_updates);
819 $this->assertSame(45, $record_repo->exposed_updates[0]['obj_id']);
820 $this->assertSame(false, $record_repo->exposed_updates[0]['deleted']);
821 $this->assertXmlStringEqualsXmlString(
822 '<el>45 changed</el>',
823 $record_repo->exposed_updates[0]['metadata']
824 );
825 $this->assertEquals(
826 [
827 ['obj_id' => 32, 'ref_id' => 12332, 'type' => 'type_32'],
828 ['obj_id' => 45, 'ref_id' => 12345, 'type' => 'type_45']
829 ],
830 $writer->exposed_params
831 );
832 $this->assertCount(1, $record_repo->exposed_deletions);
833 }

◆ testRunWithdrawDeprecatedReferenceBlocked()

ILIAS\MetaData\OERHarvester\CronJob\AutomaticPublisherTest::testRunWithdrawDeprecatedReferenceBlocked ( )

Definition at line 457 of file AutomaticPublisherTest.php.

457 : void
458 {
459 $harvester = new AutomaticPublisher(
460 $publisher = $this->getPublisher(),
461 $this->getSettings(false, false, ['type', 'second type'], [12, 5]),
462 $this->getObjectHandler(),
463 $this->getStatusRepository([32 => 12332, 45 => 12345], [32]),
465 $this->getSearchFactory(45, 32),
466 new NullLOMRepository(),
467 $this->getXMLWriter(),
468 $this->getNullLogger()
469 );
470
471 $result = $harvester->run($this->getCronResultWrapper());
472
473 $this->assertSame(JobResult::STATUS_OK, $result->exposed_status);
474 $this->assertSame(
475 'Withdrew 1 deprecated objects.<br>' .
476 'Updated 0 published objects.',
477 $result->exposed_message
478 );
479 $this->assertSame([32], $publisher->exposed_withdrawn_objects);
480 }

◆ testRunWithdrawDeprecatedReferenceContinueDespiteError()

ILIAS\MetaData\OERHarvester\CronJob\AutomaticPublisherTest::testRunWithdrawDeprecatedReferenceContinueDespiteError ( )

Definition at line 532 of file AutomaticPublisherTest.php.

532 : void
533 {
534 $harvester = new AutomaticPublisher(
535 $publisher = $this->getPublisher(45),
536 $this->getSettings(false, false, ['type', 'second type'], [12, 5]),
537 $this->getObjectHandler(),
538 $this->getStatusRepository([32 => 12332, 45 => 12345, 67 => 12367]),
540 $this->getSearchFactory(),
541 new NullLOMRepository(),
542 $this->getXMLWriter(),
543 $this->getNullLogger()
544 );
545
546 $result = $harvester->run($this->getCronResultWrapper());
547
548 $this->assertSame(JobResult::STATUS_OK, $result->exposed_status);
549 $this->assertSame(
550 'Withdrew 2 deprecated objects.<br>' .
551 'Updated 0 published objects.',
552 $result->exposed_message
553 );
554 $this->assertSame([32, 67], $publisher->exposed_withdrawn_objects);
555 }

◆ testRunWithdrawDeprecatedReferenceIncorrectTypeOrCopyright()

ILIAS\MetaData\OERHarvester\CronJob\AutomaticPublisherTest::testRunWithdrawDeprecatedReferenceIncorrectTypeOrCopyright ( )

Definition at line 428 of file AutomaticPublisherTest.php.

428 : void
429 {
430 $harvester = new AutomaticPublisher(
431 $publisher = $this->getPublisher(),
432 $this->getSettings(false, false, ['type', 'second type'], [12, 5]),
433 $this->getObjectHandler(),
434 $this->getStatusRepository([32 => 12332, 45 => 12345]),
436 $search_factory = $this->getSearchFactory(45),
437 new NullLOMRepository(),
438 $this->getXMLWriter(),
439 $this->getNullLogger()
440 );
441
442 $result = $harvester->run($this->getCronResultWrapper());
443
444 $this->assertSame(JobResult::STATUS_OK, $result->exposed_status);
445 $this->assertSame(
446 'Withdrew 1 deprecated objects.<br>' .
447 'Updated 0 published objects.',
448 $result->exposed_message
449 );
450 $this->assertSame(
451 [['restricted' => true, 'types' => ['type', 'second type'], 'entries' => [12, 5]]],
452 $search_factory->exposed_search_params
453 );
454 $this->assertSame([32], $publisher->exposed_withdrawn_objects);
455 }

◆ testRunWithdrawDeprecatedReferenceObjectDeleted()

ILIAS\MetaData\OERHarvester\CronJob\AutomaticPublisherTest::testRunWithdrawDeprecatedReferenceObjectDeleted ( )

Definition at line 482 of file AutomaticPublisherTest.php.

482 : void
483 {
484 $harvester = new AutomaticPublisher(
485 $publisher = $this->getPublisher(),
486 $this->getSettings(false, false, ['type', 'second type'], [12, 5]),
487 $this->getObjectHandler([32]),
488 $this->getStatusRepository([32 => 12332, 45 => 12345]),
490 $this->getSearchFactory(45, 32),
491 new NullLOMRepository(),
492 $this->getXMLWriter(),
493 $this->getNullLogger()
494 );
495
496 $result = $harvester->run($this->getCronResultWrapper());
497
498 $this->assertSame(JobResult::STATUS_OK, $result->exposed_status);
499 $this->assertSame(
500 'Withdrew 1 deprecated objects.<br>' .
501 'Updated 0 published objects.',
502 $result->exposed_message
503 );
504 $this->assertSame([32], $publisher->exposed_withdrawn_objects);
505 }

◆ testRunWithdrawDeprecatedReferenceReferenceDeleted()

ILIAS\MetaData\OERHarvester\CronJob\AutomaticPublisherTest::testRunWithdrawDeprecatedReferenceReferenceDeleted ( )

Definition at line 507 of file AutomaticPublisherTest.php.

507 : void
508 {
509 $harvester = new AutomaticPublisher(
510 $publisher = $this->getPublisher(),
511 $this->getSettings(false, false, ['type', 'second type'], [12, 5]),
512 $this->getObjectHandler([], 0, [], [12332]),
513 $this->getStatusRepository([32 => 12332, 45 => 12345]),
515 $this->getSearchFactory(45, 32),
516 new NullLOMRepository(),
517 $this->getXMLWriter(),
518 $this->getNullLogger()
519 );
520
521 $result = $harvester->run($this->getCronResultWrapper());
522
523 $this->assertSame(JobResult::STATUS_OK, $result->exposed_status);
524 $this->assertSame(
525 'Withdrew 1 deprecated objects.<br>' .
526 'Updated 0 published objects.',
527 $result->exposed_message
528 );
529 $this->assertSame([32], $publisher->exposed_withdrawn_objects);
530 }

◆ testRunWithUnforeseenError()

ILIAS\MetaData\OERHarvester\CronJob\AutomaticPublisherTest::testRunWithUnforeseenError ( )

Definition at line 861 of file AutomaticPublisherTest.php.

861 : void
862 {
863 $harvester = new AutomaticPublisher(
864 $this->getPublisher(),
865 $this->getSettings(false, false, ['type', 'second type'], [12, 5]),
866 $this->getObjectHandler(),
867 $this->getStatusRepository([], [], true),
869 $this->getSearchFactory(),
870 new NullLOMRepository(),
871 $this->getXMLWriter(),
872 $this->getNullLogger()
873 );
874
875 $result = $harvester->run($this->getCronResultWrapper());
876
877 $this->assertSame(JobResult::STATUS_FAIL, $result->exposed_status);
878 $this->assertSame(
879 'error',
880 $result->exposed_message
881 );
882 }
final const int STATUS_FAIL
Definition: JobResult.php:30

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