2020
2121use PHPUnit \Framework \TestCase ;
2222use ILIAS \Cron \Schedule \CronJobScheduleType ;
23+ use ILIAS \Cron \CronJob ;
2324
2425/**
2526 * Class CronJobEntityTest
@@ -36,7 +37,47 @@ private function getEntity(
3637 int $ schedule_value = 5 ,
3738 bool $ is_plugin = false
3839 ): ilCronJobEntity {
39- $ job_instance ??= $ this ->createMock (ilCronJob::class);
40+ $ job_instance ??= new class (
41+ $ schedule_type ,
42+ $ schedule_value
43+ ) implements CronJob {
44+ public function __construct (
45+ private $ schedule_type ,
46+ private $ schedule_value
47+ ) {
48+ }
49+ public function getId (): string
50+ {
51+ return 'phpunit ' ;
52+ }
53+ public function getComponent (): string
54+ {
55+ return 'phpunit ' ;
56+ }
57+ public function getTitle (): string
58+ {
59+ return 'phpunit ' ;
60+ }
61+ public function getDescription (): string
62+ {
63+ return 'phpunit ' ;
64+ }
65+ public function getScheduleType (): ?CronJobScheduleType
66+ {
67+ return $ this ->schedule_type ;
68+ }
69+ public function getScheduleValue (): ?int
70+ {
71+ return $ this ->schedule_value ;
72+ }
73+ public function run (): \ilCronJobResult
74+ {
75+ return new \ilCronJobResult ();
76+ }
77+ public function init (): void
78+ {
79+ }
80+ };
4081
4182 if ($ schedule_type === null ) {
4283 $ schedule_type = CronJobScheduleType::SCHEDULE_TYPE_IN_MINUTES ->value ;
@@ -91,9 +132,14 @@ public function testCollectionCanBeChanged(ilCronJobEntities $entities): ilCronJ
91132 */
92133 public function testCollectionCanBeFilteredAndSliced (ilCronJobEntities $ entities ): void
93134 {
94- $ this ->assertCount (0 , $ entities ->filter (static function (ilCronJobEntity $ entity ): bool {
95- return $ entity ->getJobId () !== 'phpunit ' ;
96- }));
135+ $ this ->assertCount (
136+ 0 ,
137+ $ entities ->filter (
138+ static function (ilCronJobEntity $ entity ): bool {
139+ return $ entity ->getJobId () !== 'phpunit ' ;
140+ }
141+ )
142+ );
97143
98144 $ this ->assertCount (1 , $ entities ->slice (1 , 1 ));
99145 }
0 commit comments