ILIAS  release_7 Revision v7.30-3-g800a261c036
ilStudyProgrammeCronAboutToExpireTest Class Reference
+ Inheritance diagram for ilStudyProgrammeCronAboutToExpireTest:
+ Collaboration diagram for ilStudyProgrammeCronAboutToExpireTest:

Public Member Functions

 setUp ()
 
 testRiskyToFailNoSettings ()
 
 testRiskyToFailNoRepos ()
 
 testRiskyToFail ()
 

Detailed Description

Definition at line 7 of file ilStudyProgrammeCronAboutToExpireTest.php.

Member Function Documentation

◆ setUp()

ilStudyProgrammeCronAboutToExpireTest::setUp ( )

Definition at line 9 of file ilStudyProgrammeCronAboutToExpireTest.php.

9 : void
10 {
11 $this->job = $this
12 ->getMockBuilder(ilPrgUserNotRestartedCronJob::class)
13 ->disableOriginalConstructor()
14 ->onlyMethods(['getEvents', 'getSettingsRepository', 'getProgressRepository', 'log'])
15 ->getMock();
16
17 $this->settings_repo = $this->getMockBuilder(ilStudyProgrammeSettingsDBRepository::class)
18 ->disableOriginalConstructor()
19 ->onlyMethods(['getProgrammeIdsWithMailsForExpiringValidity'])
20 ->getMock();
21
22 $this->progress_repo = $this->getMockBuilder(ilStudyProgrammeProgressDBRepository::class)
23 ->disableOriginalConstructor()
24 ->onlyMethods(['getAboutToExpire'])
25 ->getMock();
26
27 $this->events = new ProgrammeEventsMock();
28 }

◆ testRiskyToFail()

ilStudyProgrammeCronAboutToExpireTest::testRiskyToFail ( )

Definition at line 80 of file ilStudyProgrammeCronAboutToExpireTest.php.

81 {
82 $this->settings_repo
83 ->expects($this->once())
84 ->method('getProgrammeIdsWithMailsForExpiringValidity')
85 ->willReturn([71 => 2]);
86
87 $progress_1 = (new ilStudyProgrammeProgress(1))->withUserId(11)->withNodeId(71)->withAssignmentId(61);
88 $progress_2 = (new ilStudyProgrammeProgress(2))->withUserId(22)->withNodeId(71)->withAssignmentId(62);
89 $progress_3 = (new ilStudyProgrammeProgress(3))->withUserId(33)->withNodeId(71)->withAssignmentId(63);
90
91 $expected_events = [
92 ['informUserToRestart', ["usr_id" => 11, "ass_id" => 61, 'progress_id' => 1]],
93 ['informUserToRestart', ["usr_id" => 22, "ass_id" => 62, 'progress_id' => 2]],
94 ['informUserToRestart', ["usr_id" => 33, "ass_id" => 63, 'progress_id' => 3]]
95 ];
96
97 $this->progress_repo
98 ->expects($this->once())
99 ->method('getAboutToExpire')
100 ->willReturn([
101 $progress_1,
102 $progress_2,
103 $progress_3
104 ]);
105
106 $this->job->expects($this->once())
107 ->method('getSettingsRepository')
108 ->willReturn($this->settings_repo);
109
110 $this->job->expects($this->once())
111 ->method('getProgressRepository')
112 ->willReturn($this->progress_repo);
113
114 $this->job->expects($this->once())
115 ->method('getEvents')
116 ->willReturn($this->events);
117
118 $this->job->run();
119 $this->assertEquals($expected_events, $this->events->raised);
120 }
Class ilStudyProgrammeProgress.

◆ testRiskyToFailNoRepos()

ilStudyProgrammeCronAboutToExpireTest::testRiskyToFailNoRepos ( )

Definition at line 51 of file ilStudyProgrammeCronAboutToExpireTest.php.

52 {
53 $this->settings_repo
54 ->expects($this->once())
55 ->method('getProgrammeIdsWithMailsForExpiringValidity')
56 ->willReturn([
57 71 => 2, //id 71, 2 days
58 72 => 4
59 ]);
60
61 $this->progress_repo
62 ->expects($this->once())
63 ->method('getAboutToExpire')
64 ->willReturn([]);
65
66 $this->job->expects($this->once())
67 ->method('getSettingsRepository')
68 ->willReturn($this->settings_repo);
69
70 $this->job->expects($this->once())
71 ->method('getProgressRepository')
72 ->willReturn($this->progress_repo);
73
74 $this->job->expects($this->never())
75 ->method('getEvents');
76
77 $this->job->run();
78 }

◆ testRiskyToFailNoSettings()

ilStudyProgrammeCronAboutToExpireTest::testRiskyToFailNoSettings ( )

Definition at line 30 of file ilStudyProgrammeCronAboutToExpireTest.php.

30 : void
31 {
32 $this->settings_repo
33 ->expects($this->once())
34 ->method('getProgrammeIdsWithMailsForExpiringValidity')
35 ->willReturn([]);
36
37
38 $this->job->expects($this->once())
39 ->method('getSettingsRepository')
40 ->willReturn($this->settings_repo);
41
42 $this->job->expects($this->never())
43 ->method('getProgressRepository');
44
45 $this->job->expects($this->never())
46 ->method('getEvents');
47
48 $this->job->run();
49 }

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