ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilPrgRestartAssignmentsCronJobTest Class Reference
+ Inheritance diagram for ilPrgRestartAssignmentsCronJobTest:
+ Collaboration diagram for ilPrgRestartAssignmentsCronJobTest:

Public Member Functions

 testRestartAssignmentsForNoRelevantProgrammes ()
 
 testRestartAssignmentsForRelevantProgrammes ()
 
 testRestartAssignmentsEvents ()
 

Protected Member Functions

 setUp ()
 

Protected Attributes

ilPrgRestartAssignmentsCronJobMock $job
 
ilStudyProgrammeSettingsDBRepository $settings_repo
 
ilPRGAssignmentDBRepository $assignment_repo
 
ProgrammeEventsMock $events
 

Detailed Description

Definition at line 53 of file ilPrgRestartAssignmentsCronJobTest.php.

Member Function Documentation

◆ setUp()

ilPrgRestartAssignmentsCronJobTest::setUp ( )
protected

Definition at line 60 of file ilPrgRestartAssignmentsCronJobTest.php.

60  : void
61  {
62  $this->events = new ProgrammeEventsMock();
63 
64  $this->settings_repo = $this->getMockBuilder(ilStudyProgrammeSettingsDBRepository::class)
65  ->disableOriginalConstructor()
66  ->onlyMethods(['getProgrammeIdsWithReassignmentForExpiringValidity'])
67  ->getMock();
68 
69  $this->adapter = $this->getMockBuilder(ilPrgRestart::class)
70  ->setConstructorArgs([$this->settings_repo, $this->events])
71  ->getMock();
72 
73  $this->real_adapter = new ilPrgRestart($this->settings_repo, $this->events);
74 
75  $this->assignment_repo = $this->getMockBuilder(ilPRGAssignmentDBRepository::class)
76  ->disableOriginalConstructor()
77  ->onlyMethods(['getAboutToExpire', 'store'])
78  ->getMock();
79 
80  $this->prg = $this->getMockBuilder(ilObjStudyProgramme::class)
81  ->disableOriginalConstructor()
82  ->onlyMethods(['getApplicableMembershipSourceForUser', 'getSettings', 'assignUser', 'getRefIdFor'])
83  ->getMock();
84 
85  $this->job = new ilPrgRestartAssignmentsCronJobMock($this->assignment_repo, $this->adapter, $this->prg);
86  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ testRestartAssignmentsEvents()

ilPrgRestartAssignmentsCronJobTest::testRestartAssignmentsEvents ( )

Definition at line 172 of file ilPrgRestartAssignmentsCronJobTest.php.

References ilPrgRestartAssignmentsCronJob\run(), and ilPRGProgress\STATUS_COMPLETED.

172  : void
173  {
175  $ass1 = (new ilPRGAssignment(42, 7))->withProgressTree($pgs1);
176  $ass2 = (new ilPRGAssignment(43, 8))->withProgressTree($pgs1)
177  ->withManuallyAssigned(true);
178 
179  $this->settings_repo
180  ->expects($this->once())
181  ->method('getProgrammeIdsWithReassignmentForExpiringValidity')
182  ->willReturn([
183  42=>3,
184  43=>3
185  ]);
186 
187  $this->assignment_repo
188  ->expects($this->once())
189  ->method('getAboutToExpire')
190  ->willReturn([$ass1, $ass2]);
191  $this->prg
192  ->expects($this->exactly(2))
193  ->method('assignUser')
194  ->will($this->onConsecutiveCalls($ass1, $ass2));
195 
196  $job = new ilPrgRestartAssignmentsCronJobMock($this->assignment_repo, $this->real_adapter, $this->prg);
197  $job->run();
198 
199  $this->assertEquals(2, count($job->logs));
200  $expected_events = [
201  ['userReAssigned', ["ass_id" => 42, 'root_prg_id' => 11]],
202  ['userReAssigned', ["ass_id" => 43, 'root_prg_id' => 11]]
203  ];
204  $this->assertEquals($expected_events, $this->events->raised);
205  }
A Progress is the status of a user on a single node of an assignment; it is unique by assignment_id:u...
Assignments are relations of users to a PRG; They hold progress-information for (sub-)nodes of the PR...
+ Here is the call graph for this function:

◆ testRestartAssignmentsForNoRelevantProgrammes()

ilPrgRestartAssignmentsCronJobTest::testRestartAssignmentsForNoRelevantProgrammes ( )

Definition at line 88 of file ilPrgRestartAssignmentsCronJobTest.php.

88  : void
89  {
90  $this->adapter
91  ->expects($this->once())
92  ->method('getRelevantProgrammeIds')
93  ->willReturn([]);
94  $this->assignment_repo
95  ->expects($this->never())
96  ->method('getAboutToExpire');
97  $this->assignment_repo
98  ->expects($this->never())
99  ->method('store');
100  $this->adapter
101  ->expects($this->never())
102  ->method('actOnSingleAssignment');
103  $this->job->run();
104  }

◆ testRestartAssignmentsForRelevantProgrammes()

ilPrgRestartAssignmentsCronJobTest::testRestartAssignmentsForRelevantProgrammes ( )

Definition at line 106 of file ilPrgRestartAssignmentsCronJobTest.php.

References ILIAS\LTI\ToolProvider\$settings, and ilPRGProgress\STATUS_COMPLETED.

106  : void
107  {
109  $ass1 = (new ilPRGAssignment(42, 7))
110  ->withProgressTree($pgs1)
111  ->withManuallyAssigned(false);//will not be restarted
112  $ass2 = (new ilPRGAssignment(43, 8))
113  ->withProgressTree($pgs1)
114  ->withManuallyAssigned(true);
115  $this->adapter
116  ->expects($this->once())
117  ->method('getRelevantProgrammeIds')
118  ->willReturn([
119  1=>3
120  ]);
121  $this->assignment_repo
122  ->expects($this->once())
123  ->method('getAboutToExpire')
124  ->willReturn([$ass1, $ass2]);
125 
126  $this->assignment_repo
127  ->expects($this->exactly(1))
128  ->method('store');
129 
130  $validity_settings = $this->getMockBuilder(ilStudyProgrammeValidityOfAchievedQualificationSettings::class)
131  ->disableOriginalConstructor()
132  ->onlyMethods(['getRestartRecheck'])
133  ->getMock();
134 
135  $validity_settings
136  ->expects($this->exactly(2))
137  ->method('getRestartRecheck')
138  ->willReturn(true);
139 
140  $settings = $this->getMockBuilder(ilStudyProgrammeSettings::class)
141  ->disableOriginalConstructor()
142  ->onlyMethods(['getValidityOfQualificationSettings'])
143  ->getMock();
144  $settings
145  ->expects($this->exactly(2))
146  ->method('getValidityOfQualificationSettings')
147  ->willReturn($validity_settings);
148 
149  $this->prg
150  ->expects($this->exactly(2))
151  ->method('getSettings')
152  ->willReturn($settings);
153 
154  $this->prg
155  ->expects($this->exactly(1))
156  ->method('getApplicableMembershipSourceForUser')
157  ->willReturn(null);
158 
159  $this->prg
160  ->expects($this->exactly(1))
161  ->method('assignUser')
162  ->willReturn($ass1);
163 
164 
165  $this->adapter
166  ->expects($this->exactly(1))
167  ->method('actOnSingleAssignment');
168 
169  $this->job->run();
170  }
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
A Progress is the status of a user on a single node of an assignment; it is unique by assignment_id:u...
Assignments are relations of users to a PRG; They hold progress-information for (sub-)nodes of the PR...

Field Documentation

◆ $assignment_repo

ilPRGAssignmentDBRepository ilPrgRestartAssignmentsCronJobTest::$assignment_repo
protected

Definition at line 57 of file ilPrgRestartAssignmentsCronJobTest.php.

◆ $events

ProgrammeEventsMock ilPrgRestartAssignmentsCronJobTest::$events
protected

Definition at line 58 of file ilPrgRestartAssignmentsCronJobTest.php.

◆ $job

ilPrgRestartAssignmentsCronJobMock ilPrgRestartAssignmentsCronJobTest::$job
protected

Definition at line 55 of file ilPrgRestartAssignmentsCronJobTest.php.

◆ $settings_repo

ilStudyProgrammeSettingsDBRepository ilPrgRestartAssignmentsCronJobTest::$settings_repo
protected

Definition at line 56 of file ilPrgRestartAssignmentsCronJobTest.php.


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