19 declare(strict_types=1);
35 int $schedule_type = null,
36 int $schedule_value = 5,
37 bool $is_plugin =
false 39 $job_instance ??= $this->createMock(ilCronJob::class);
41 if ($schedule_type === null) {
42 $schedule_type = CronJobScheduleType::SCHEDULE_TYPE_IN_MINUTES->value;
46 'job_id' =>
'phpunit',
47 'component' =>
'phpunit',
48 'schedule_type' => $schedule_type,
49 'schedule_value' => $schedule_value,
51 'job_status_user_id' => 6,
52 'job_status_type' => 1,
53 'job_status_ts' => time(),
55 'job_result_user_id' => 6,
57 'job_result_message' =>
'msg',
58 'job_result_type' => 1,
59 'job_result_ts' => time(),
62 'running_ts' => time(),
63 'job_result_dur' => time(),
72 $this->assertCount(2, $entities->toArray());
84 $this->assertCount(3, $entities->
toArray());
95 return $entity->
getJobId() !==
'phpunit';
98 $this->assertCount(1, $entities->
slice(1, 1));
103 $job_instance = $this->createMock(ilCronJob::class);
104 $job_instance->method(
'hasFlexibleSchedule')->willReturn(
true);
106 $entity = $this->
getEntity($job_instance);
107 $this->assertSame(CronJobScheduleType::SCHEDULE_TYPE_IN_MINUTES, $entity->getEffectiveScheduleType());
108 $this->assertSame(5, $entity->getEffectiveScheduleValue());
110 $another_job_instance = $this->createMock(ilCronJob::class);
111 $another_job_instance->method(
'hasFlexibleSchedule')->willReturn(
false);
112 $another_job_instance->method(
'getDefaultScheduleType')->willReturn(CronJobScheduleType::SCHEDULE_TYPE_IN_HOURS);
113 $another_job_instance->method(
'getDefaultScheduleValue')->willReturn(5);
115 $another_entity = $this->
getEntity($another_job_instance, CronJobScheduleType::SCHEDULE_TYPE_DAILY->value);
116 $this->assertSame(CronJobScheduleType::SCHEDULE_TYPE_IN_HOURS, $another_entity->getEffectiveScheduleType());
117 $this->assertSame(5, $another_entity->getEffectiveScheduleValue());
119 $yet_another_job_instance = $this->createMock(ilCronJob::class);
120 $yet_another_job_instance->method(
'hasFlexibleSchedule')->willReturn(
true);
121 $yet_another_job_instance->method(
'getDefaultScheduleType')->willReturn(CronJobScheduleType::SCHEDULE_TYPE_IN_HOURS);
122 $yet_another_job_instance->method(
'getDefaultScheduleValue')->willReturn(5);
124 $yet_another_entity = $this->
getEntity($yet_another_job_instance, 0);
125 $this->assertSame(CronJobScheduleType::SCHEDULE_TYPE_IN_HOURS, $yet_another_entity->getEffectiveScheduleType());
126 $this->assertSame(5, $yet_another_entity->getEffectiveScheduleValue());
slice(int $offset, ?int $length=null)
Extracts a slice of $length elements starting at position $offset from the Collection.
testCollectionCanBeFilteredAndSliced(ilCronJobEntities $entities)
testCollectionCanBeChanged
testEffectiveScheduleCanBeDetermined()
getEntity(ilCronJob $job_instance=null, int $schedule_type=null, int $schedule_value=5, bool $is_plugin=false)
final const CODE_NO_RESULT
testCollectionCanBeChanged(ilCronJobEntities $entities)
testEntityCollectionCanBeCreatedWithItems
testEntityCollectionCanBeCreatedWithItems()
filter(callable $callable)
Returns all the elements of this collection that satisfy the predicate $callable. ...
add(ilCronJobEntity $job)