1 <?php declare(strict_types=1);
3 require_once(__DIR__ .
"/../../../../libs/composer/vendor/autoload.php");
4 require_once(__DIR__ .
"/../prg_mocks.php");
9 public function setUp() : void
12 ->getMockBuilder(ilPrgUserRiskyToFailCronJob::class)
13 ->disableOriginalConstructor()
14 ->onlyMethods([
'getEvents',
'getSettingsRepository',
'getProgressRepository',
'log'])
17 $this->settings_repo = $this->getMockBuilder(ilStudyProgrammeSettingsDBRepository::class)
18 ->disableOriginalConstructor()
19 ->onlyMethods([
'getProgrammeIdsWithRiskyToFailSettings'])
22 $this->progress_repo = $this->getMockBuilder(ilStudyProgrammeProgressDBRepository::class)
23 ->disableOriginalConstructor()
24 ->onlyMethods([
'getRiskyToFail'])
27 $this->events =
new ProgrammeEventsMock();
33 ->expects($this->once())
34 ->method(
'getProgrammeIdsWithRiskyToFailSettings')
38 $this->job->expects($this->once())
39 ->method(
'getSettingsRepository')
40 ->willReturn($this->settings_repo);
42 $this->job->expects($this->never())
43 ->method(
'getProgressRepository');
45 $this->job->expects($this->never())
46 ->method(
'getEvents');
54 ->expects($this->once())
55 ->method(
'getProgrammeIdsWithRiskyToFailSettings')
62 ->expects($this->once())
63 ->method(
'getRiskyToFail')
66 $this->job->expects($this->once())
67 ->method(
'getSettingsRepository')
68 ->willReturn($this->settings_repo);
70 $this->job->expects($this->once())
71 ->method(
'getProgressRepository')
72 ->willReturn($this->progress_repo);
74 $this->job->expects($this->never())
75 ->method(
'getEvents');
83 ->expects($this->once())
84 ->method(
'getProgrammeIdsWithRiskyToFailSettings')
85 ->willReturn([71 => 2]);
92 [
'userRiskyToFail', [
"progress_id" => 1,
"usr_id" => 11]],
93 [
'userRiskyToFail', [
"progress_id" => 2,
"usr_id" => 22]],
94 [
'userRiskyToFail', [
"progress_id" => 3,
"usr_id" => 33]]
98 ->expects($this->once())
99 ->method(
'getRiskyToFail')
106 $this->job->expects($this->once())
107 ->method(
'getSettingsRepository')
108 ->willReturn($this->settings_repo);
110 $this->job->expects($this->once())
111 ->method(
'getProgressRepository')
112 ->willReturn($this->progress_repo);
114 $this->job->expects($this->once())
115 ->method(
'getEvents')
116 ->willReturn($this->events);
119 $this->assertEquals($expected_events, $this->events->raised);
testRiskyToFailNoSettings()
Class ilStudyProgrammeProgress.