19 declare(strict_types=1);
31 $clock_factory = $this->createMock(
ILIAS\
Data\
Clock\ClockFactory::class);
33 $clock_factory->method(
'system')->willReturn(
49 return $clock_factory;
54 $db = $this->createMock(ilDBInterface::class);
55 $setting = $this->getMockBuilder(ilSetting::class)->disableOriginalConstructor()->getMock();
56 $logger = $this->getMockBuilder(ilLogger::class)->disableOriginalConstructor()->getMock();
57 $repository = $this->createMock(JobRepository::class);
58 $job = $this->createMock(CronJob::class);
59 $user = $this->getMockBuilder(ilObjUser::class)
60 ->disableOriginalConstructor()
61 ->onlyMethods([
'getId'])
74 $repository->expects($this->once())->method(
'updateJobResult')->with(
76 $clock_factory->system()->now(),
78 $this->isInstanceOf(JobResult::class),
82 $repository->expects($this->once())->method(
'resetJob')->with(
86 $repository->expects($this->once())->method(
'activateJob')->with(
88 $clock_factory->system()->now(),
93 $job->expects($this->once())->method(
'activationWasToggled')->with(
99 $cronManager->resetJob($job, $user);
104 $db = $this->createMock(ilDBInterface::class);
105 $setting = $this->getMockBuilder(ilSetting::class)->disableOriginalConstructor()->getMock();
106 $logger = $this->getMockBuilder(ilLogger::class)->disableOriginalConstructor()->getMock();
107 $repository = $this->createMock(JobRepository::class);
108 $job = $this->createMock(CronJob::class);
109 $user = $this->getMockBuilder(ilObjUser::class)
110 ->disableOriginalConstructor()
111 ->onlyMethods([
'getId'])
125 [$job, $clock_factory->system()->now(), $user,
true],
126 [$job, $clock_factory->system()->now(), $user,
false]
129 ->expects($this->exactly(2))
130 ->method(
'activateJob')
131 ->willReturnCallback(
132 function ($job, $date, $user, $flag) use (&$consecutive):
void {
133 [$ejob, $edate, $euser, $eflag] = array_shift($consecutive);
134 $this->assertEquals($ejob, $job);
135 $this->assertEquals($edate, $date);
136 $this->assertEquals($euser, $user);
137 $this->assertEquals($eflag, $flag);
141 $job->expects($this->exactly(2))->method(
'activationWasToggled')->with(
147 $cronManager->activateJob($job, $user,
true);
148 $cronManager->activateJob($job, $user,
false);
153 $db = $this->createMock(ilDBInterface::class);
154 $setting = $this->getMockBuilder(ilSetting::class)->disableOriginalConstructor()->getMock();
155 $logger = $this->getMockBuilder(ilLogger::class)->disableOriginalConstructor()->getMock();
156 $repository = $this->createMock(JobRepository::class);
157 $job = $this->createMock(CronJob::class);
158 $user = $this->getMockBuilder(ilObjUser::class)
159 ->disableOriginalConstructor()
160 ->onlyMethods([
'getId'])
174 [$job, $clock_factory->system()->now(), $user,
true],
175 [$job, $clock_factory->system()->now(), $user,
false]
178 ->expects($this->exactly(2))
179 ->method(
'deactivateJob')
180 ->willReturnCallback(
181 function ($job, $date, $user, $flag) use (&$consecutive):
void {
182 [$ejob, $edate, $euser, $eflag] = array_shift($consecutive);
183 $this->assertEquals($ejob, $job);
184 $this->assertEquals($edate, $date);
185 $this->assertEquals($euser, $user);
186 $this->assertEquals($eflag, $flag);
190 $job->expects($this->exactly(2))->method(
'activationWasToggled')->with(
196 $cronManager->deactivateJob($job, $user,
true);
197 $cronManager->deactivateJob($job, $user,
false);
testCronManagerActivatesJobWhenJobWasReset()
Interface Observer Contains several chained tasks and infos about them.
testCronManagerNotifiesJobWhenJobGetsActivated()
__construct(Container $dic, ilPlugin $plugin)
testCronManagerNotifiesJobWhenJobGetsDeactivated()