19 declare(strict_types=1);
32 ?
int $schedule_type =
null,
33 int $schedule_value = 5,
34 bool $is_plugin =
false 36 $job_instance ??= $this->createMock(CronJob::class);
38 if ($schedule_type ===
null) {
39 $schedule_type = JobScheduleType::IN_MINUTES->value;
43 'job_id' =>
'phpunit',
44 'component' =>
'phpunit',
45 'schedule_type' => $schedule_type,
46 'schedule_value' => $schedule_value,
48 'job_status_user_id' => 6,
49 'job_status_type' => 1,
50 'job_status_ts' => time(),
51 'job_result_status' => JobResult::STATUS_OK,
52 'job_result_user_id' => 6,
53 'job_result_code' => JobResult::CODE_NO_RESULT,
54 'job_result_message' =>
'msg',
55 'job_result_type' => 1,
56 'job_result_ts' => time(),
59 'running_ts' => time(),
60 'job_result_dur' => time(),
67 $entities = new \ILIAS\Cron\Job\Collection\JobEntities($this->
getEntity(), $this->
getEntity());
69 $this->assertCount(2, $entities->toArray());
74 #[Depends('testEntityCollectionCanBeCreatedWithItems')] 76 \
ILIAS\Cron\Job\Collection\JobEntities $entities
77 ): \
ILIAS\Cron\Job\Collection\JobEntities {
80 $this->assertCount(3, $entities->toArray());
85 #[Depends('testCollectionCanBeChanged')] 88 $this->assertCount(0, $entities->filter(
static function (
JobEntity $entity):
bool {
89 return $entity->
getJobId() !==
'phpunit';
92 $this->assertCount(1, $entities->slice(1, 1));
97 $job_instance = $this->createMock(CronJob::class);
98 $job_instance->method(
'hasFlexibleSchedule')->willReturn(
true);
100 $entity = $this->
getEntity($job_instance);
101 $this->assertSame(JobScheduleType::IN_MINUTES, $entity->getEffectiveScheduleType());
102 $this->assertSame(5, $entity->getEffectiveScheduleValue());
104 $another_job_instance = $this->createMock(CronJob::class);
105 $another_job_instance->method(
'hasFlexibleSchedule')->willReturn(
false);
106 $another_job_instance->method(
'getDefaultScheduleType')->willReturn(
107 JobScheduleType::IN_HOURS
109 $another_job_instance->method(
'getDefaultScheduleValue')->willReturn(5);
111 $another_entity = $this->
getEntity($another_job_instance, JobScheduleType::DAILY->value);
112 $this->assertSame(JobScheduleType::IN_HOURS, $another_entity->getEffectiveScheduleType());
113 $this->assertSame(5, $another_entity->getEffectiveScheduleValue());
115 $yet_another_job_instance = $this->createMock(CronJob::class);
116 $yet_another_job_instance->method(
'hasFlexibleSchedule')->willReturn(
true);
117 $yet_another_job_instance->method(
'getDefaultScheduleType')->willReturn(
118 JobScheduleType::IN_HOURS
120 $yet_another_job_instance->method(
'getDefaultScheduleValue')->willReturn(5);
122 $yet_another_entity = $this->
getEntity($yet_another_job_instance, 0);
123 $this->assertSame(JobScheduleType::IN_HOURS, $yet_another_entity->getEffectiveScheduleType());
124 $this->assertSame(5, $yet_another_entity->getEffectiveScheduleValue());
Interface Observer Contains several chained tasks and infos about them.
testEffectiveScheduleCanBeDetermined()
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
testCollectionCanBeFilteredAndSliced(\ILIAS\Cron\Job\Collection\JobEntities $entities)
getEntity(?CronJob $job_instance=null, ?int $schedule_type=null, int $schedule_value=5, bool $is_plugin=false)
testCollectionCanBeChanged(\ILIAS\Cron\Job\Collection\JobEntities $entities)
testEntityCollectionCanBeCreatedWithItems()