ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
CronJobEntityTest Class Reference
+ Inheritance diagram for CronJobEntityTest:
+ Collaboration diagram for CronJobEntityTest:

Public Member Functions

 testEntityCollectionCanBeCreatedWithItems ()
 
 testCollectionCanBeChanged (\ILIAS\Cron\Job\Collection\JobEntities $entities)
 testEntityCollectionCanBeCreatedWithItems More...
 
 testCollectionCanBeFilteredAndSliced (\ILIAS\Cron\Job\Collection\JobEntities $entities)
 testCollectionCanBeChanged More...
 
 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 27 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
Parameters
CronJob | null$job_instance

Definition at line 32 of file CronJobEntityTest.php.

References null.

Referenced by testCollectionCanBeChanged(), testEffectiveScheduleCanBeDetermined(), and testEntityCollectionCanBeCreatedWithItems().

37  : JobEntity {
38  $job_instance ??= $this->createMock(CronJob::class);
39 
40  if ($schedule_type === null) {
41  $schedule_type = JobScheduleType::IN_MINUTES->value;
42  }
43 
44  return new JobEntity($job_instance, [
45  'job_id' => 'phpunit',
46  'component' => 'phpunit',
47  'schedule_type' => $schedule_type,
48  'schedule_value' => $schedule_value,
49  'job_status' => 1,
50  'job_status_user_id' => 6,
51  'job_status_type' => 1,
52  'job_status_ts' => time(),
53  'job_result_status' => JobResult::STATUS_OK,
54  'job_result_user_id' => 6,
55  'job_result_code' => JobResult::CODE_NO_RESULT,
56  'job_result_message' => 'msg',
57  'job_result_type' => 1,
58  'job_result_ts' => time(),
59  'class' => 'Job',
60  'path' => '/',
61  'running_ts' => time(),
62  'job_result_dur' => time(),
63  'alive_ts' => time(),
64  ], $is_plugin);
65  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ testCollectionCanBeChanged()

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

testEntityCollectionCanBeCreatedWithItems

Definition at line 79 of file CronJobEntityTest.php.

References getEntity().

81  : \ILIAS\Cron\Job\Collection\JobEntities {
82  $entities->add($this->getEntity());
83 
84  $this->assertCount(3, $entities->toArray());
85 
86  return $entities;
87  }
getEntity(?CronJob $job_instance=null, ?int $schedule_type=null, int $schedule_value=5, bool $is_plugin=false)
+ Here is the call graph for this function:

◆ testCollectionCanBeFilteredAndSliced()

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

testCollectionCanBeChanged

Definition at line 92 of file CronJobEntityTest.php.

References ILIAS\BackgroundTasks\Task\Job\JobEntity\getJobId().

92  : void
93  {
94  $this->assertCount(0, $entities->filter(static function (JobEntity $entity): bool {
95  return $entity->getJobId() !== 'phpunit';
96  }));
97 
98  $this->assertCount(1, $entities->slice(1, 1));
99  }
+ Here is the call graph for this function:

◆ testEffectiveScheduleCanBeDetermined()

CronJobEntityTest::testEffectiveScheduleCanBeDetermined ( )

Definition at line 101 of file CronJobEntityTest.php.

References getEntity().

101  : void
102  {
103  $job_instance = $this->createMock(CronJob::class);
104  $job_instance->method('hasFlexibleSchedule')->willReturn(true);
105 
106  $entity = $this->getEntity($job_instance);
107  $this->assertSame(JobScheduleType::IN_MINUTES, $entity->getEffectiveScheduleType());
108  $this->assertSame(5, $entity->getEffectiveScheduleValue());
109 
110  $another_job_instance = $this->createMock(CronJob::class);
111  $another_job_instance->method('hasFlexibleSchedule')->willReturn(false);
112  $another_job_instance->method('getDefaultScheduleType')->willReturn(
113  JobScheduleType::IN_HOURS
114  );
115  $another_job_instance->method('getDefaultScheduleValue')->willReturn(5);
116 
117  $another_entity = $this->getEntity($another_job_instance, JobScheduleType::DAILY->value);
118  $this->assertSame(JobScheduleType::IN_HOURS, $another_entity->getEffectiveScheduleType());
119  $this->assertSame(5, $another_entity->getEffectiveScheduleValue());
120 
121  $yet_another_job_instance = $this->createMock(CronJob::class);
122  $yet_another_job_instance->method('hasFlexibleSchedule')->willReturn(true);
123  $yet_another_job_instance->method('getDefaultScheduleType')->willReturn(
124  JobScheduleType::IN_HOURS
125  );
126  $yet_another_job_instance->method('getDefaultScheduleValue')->willReturn(5);
127 
128  $yet_another_entity = $this->getEntity($yet_another_job_instance, 0);
129  $this->assertSame(JobScheduleType::IN_HOURS, $yet_another_entity->getEffectiveScheduleType());
130  $this->assertSame(5, $yet_another_entity->getEffectiveScheduleValue());
131  }
getEntity(?CronJob $job_instance=null, ?int $schedule_type=null, int $schedule_value=5, bool $is_plugin=false)
+ Here is the call graph for this function:

◆ testEntityCollectionCanBeCreatedWithItems()

CronJobEntityTest::testEntityCollectionCanBeCreatedWithItems ( )

Definition at line 67 of file CronJobEntityTest.php.

References getEntity().

67  : \ILIAS\Cron\Job\Collection\JobEntities
68  {
69  $entities = new \ILIAS\Cron\Job\Collection\JobEntities($this->getEntity(), $this->getEntity());
70 
71  $this->assertCount(2, $entities->toArray());
72 
73  return $entities;
74  }
getEntity(?CronJob $job_instance=null, ?int $schedule_type=null, int $schedule_value=5, bool $is_plugin=false)
+ Here is the call graph for this function:

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