ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
CronJobEntityTest Class Reference

Class CronJobEntityTest. More...

+ Inheritance diagram for CronJobEntityTest:
+ Collaboration diagram for CronJobEntityTest:

Public Member Functions

 testEntityCollectionCanBeCreatedWithItems ()
 
 testCollectionCanBeChanged (ilCronJobEntities $entities)
 testEntityCollectionCanBeCreatedWithItems More...
 
 testCollectionCanBeFilteredAndSliced (ilCronJobEntities $entities)
 testCollectionCanBeChanged More...
 
 testEffectiveScheduleCanBeDetermined ()
 

Private Member Functions

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

Detailed Description

Class CronJobEntityTest.

Author
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de

Definition at line 28 of file CronJobEntityTest.php.

Member Function Documentation

◆ getEntity()

CronJobEntityTest::getEntity ( ilCronJob  $job_instance = null,
int  $schedule_type = null,
int  $schedule_value = 5,
bool  $is_plugin = false 
)
private
Parameters
ilCronJob | null$job_instance

Definition at line 33 of file CronJobEntityTest.php.

References ilCronJobResult\CODE_NO_RESULT, and ilCronJobResult\STATUS_OK.

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

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

◆ testCollectionCanBeChanged()

CronJobEntityTest::testCollectionCanBeChanged ( ilCronJobEntities  $entities)

testEntityCollectionCanBeCreatedWithItems

Definition at line 80 of file CronJobEntityTest.php.

References ilCronJobEntities\add(), getEntity(), and ilCronJobEntities\toArray().

81  {
82  $entities->add($this->getEntity());
83 
84  $this->assertCount(3, $entities->toArray());
85 
86  return $entities;
87  }
getEntity(ilCronJob $job_instance=null, int $schedule_type=null, int $schedule_value=5, bool $is_plugin=false)
add(ilCronJobEntity $job)
+ Here is the call graph for this function:

◆ testCollectionCanBeFilteredAndSliced()

CronJobEntityTest::testCollectionCanBeFilteredAndSliced ( ilCronJobEntities  $entities)

testCollectionCanBeChanged

Definition at line 92 of file CronJobEntityTest.php.

References ilCronJobEntities\filter(), ilCronJobEntity\getJobId(), and ilCronJobEntities\slice().

92  : void
93  {
94  $this->assertCount(0, $entities->filter(static function (ilCronJobEntity $entity): bool {
95  return $entity->getJobId() !== 'phpunit';
96  }));
97 
98  $this->assertCount(1, $entities->slice(1, 1));
99  }
slice(int $offset, ?int $length=null)
Extracts a slice of $length elements starting at position $offset from the Collection.
filter(callable $callable)
Returns all the elements of this collection that satisfy the predicate $callable. ...
+ 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(ilCronJob::class);
104  $job_instance->method('hasFlexibleSchedule')->willReturn(true);
105 
106  $entity = $this->getEntity($job_instance);
107  $this->assertSame(CronJobScheduleType::SCHEDULE_TYPE_IN_MINUTES, $entity->getEffectiveScheduleType());
108  $this->assertSame(5, $entity->getEffectiveScheduleValue());
109 
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);
114 
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());
118 
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);
123 
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());
127  }
getEntity(ilCronJob $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 68 of file CronJobEntityTest.php.

References getEntity().

69  {
70  $entities = new ilCronJobEntities($this->getEntity(), $this->getEntity());
71 
72  $this->assertCount(2, $entities->toArray());
73 
74  return $entities;
75  }
getEntity(ilCronJob $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: