ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
CronJobEntityTest Class Reference
+ Inheritance diagram for CronJobEntityTest:
+ Collaboration diagram for CronJobEntityTest:

Public Member Functions

 testEntityCollectionCanBeCreatedWithItems ()
 
 testCollectionCanBeChanged (\ILIAS\Cron\Job\Collection\JobEntities $entities)
 
 testCollectionCanBeFilteredAndSliced (\ILIAS\Cron\Job\Collection\JobEntities $entities)
 
 testEffectiveScheduleCanBeDetermined ()
 

Private Member Functions

 getEntity (?CronJob $job_instance=null, ?int $schedule_type=null, int $schedule_value=5, bool $is_plugin=false)
 

Detailed Description

Definition at line 28 of file CronJobEntityTest.php.

Member Function Documentation

◆ getEntity()

CronJobEntityTest::getEntity ( ?CronJob  $job_instance = null,
?int  $schedule_type = null,
int  $schedule_value = 5,
bool  $is_plugin = false 
)
private

Definition at line 30 of file CronJobEntityTest.php.

35 : JobEntity {
36 $job_instance ??= $this->createMock(CronJob::class);
37
38 if ($schedule_type === null) {
39 $schedule_type = JobScheduleType::IN_MINUTES->value;
40 }
41
42 return new JobEntity($job_instance, [
43 'job_id' => 'phpunit',
44 'component' => 'phpunit',
45 'schedule_type' => $schedule_type,
46 'schedule_value' => $schedule_value,
47 'job_status' => 1,
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(),
57 'class' => 'Job',
58 'path' => '/',
59 'running_ts' => time(),
60 'job_result_dur' => time(),
61 'alive_ts' => time(),
62 ], $is_plugin);
63 }

◆ testCollectionCanBeChanged()

CronJobEntityTest::testCollectionCanBeChanged ( \ILIAS\Cron\Job\Collection\JobEntities  $entities)

Definition at line 75 of file CronJobEntityTest.php.

78 $entities->add($this->getEntity());
79
80 $this->assertCount(3, $entities->toArray());
81
82 return $entities;
83 }
getEntity(?CronJob $job_instance=null, ?int $schedule_type=null, int $schedule_value=5, bool $is_plugin=false)
add(\ILIAS\Cron\Job\JobEntity $job)
Definition: JobEntities.php:48

◆ testCollectionCanBeFilteredAndSliced()

CronJobEntityTest::testCollectionCanBeFilteredAndSliced ( \ILIAS\Cron\Job\Collection\JobEntities  $entities)

Definition at line 86 of file CronJobEntityTest.php.

86 : void
87 {
88 $this->assertCount(0, $entities->filter(static function (JobEntity $entity): bool {
89 return $entity->getJobId() !== 'phpunit';
90 }));
91
92 $this->assertCount(1, $entities->slice(1, 1));
93 }

References ILIAS\Cron\Job\JobEntity\getJobId().

+ Here is the call graph for this function:

◆ testEffectiveScheduleCanBeDetermined()

CronJobEntityTest::testEffectiveScheduleCanBeDetermined ( )

Definition at line 95 of file CronJobEntityTest.php.

95 : void
96 {
97 $job_instance = $this->createMock(CronJob::class);
98 $job_instance->method('hasFlexibleSchedule')->willReturn(true);
99
100 $entity = $this->getEntity($job_instance);
101 $this->assertSame(JobScheduleType::IN_MINUTES, $entity->getEffectiveScheduleType());
102 $this->assertSame(5, $entity->getEffectiveScheduleValue());
103
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
108 );
109 $another_job_instance->method('getDefaultScheduleValue')->willReturn(5);
110
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());
114
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
119 );
120 $yet_another_job_instance->method('getDefaultScheduleValue')->willReturn(5);
121
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());
125 }

◆ testEntityCollectionCanBeCreatedWithItems()

CronJobEntityTest::testEntityCollectionCanBeCreatedWithItems ( )

Definition at line 65 of file CronJobEntityTest.php.

66 {
67 $entities = new \ILIAS\Cron\Job\Collection\JobEntities($this->getEntity(), $this->getEntity());
68
69 $this->assertCount(2, $entities->toArray());
70
71 return $entities;
72 }

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