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

Public Member Functions

 test_init_and_id ()
 
 test_assignment_id ()
 @depends test_init_and_id More...
 
 test_node_id ()
 @depends test_init_and_id More...
 
 test_user_id ()
 @depends test_init_and_id More...
 
 test_amount_of_points ()
 @depends test_init_and_id More...
 
 test_amount_of_points_invalid ()
 @depends test_init_and_id More...
 
 test_current_amount_of_points ()
 @depends test_init_and_id More...
 
 status ()
 
 test_status ($status)
 @dataProvider status More...
 
 test_status_invalid ()
 @depends test_init_and_id More...
 
 testWithLastChange ()
 @depends test_init_and_id More...
 
 test_assignment_date ()
 @depends test_init_and_id More...
 
 test_completion ()
 @depends test_init_and_id More...
 
 test_deadline ()
 @depends test_init_and_id More...
 
 test_vq_date ()
 @depends test_init_and_id More...
 
 testIndividualPlan (ilStudyProgrammeProgress $spp)
 @depends test_init_and_id More...
 
 test_invalidate ()
 @depends test_vq_date More...
 
 test_invalidate_non_expired_1 ()
 @depends test_vq_date More...
 
 test_invalidate_non_expired_2 ()
 @depends test_vq_date More...
 
 testIsSuccessful ($status, $success)
 @dataProvider status More...
 
 testHasValidQualification ()
 
 testMarkRelevant ()
 
 testMarkNotRelevant ()
 
 testMarkFailed ()
 
 testMarkNotFailed ()
 
 testMarkAccredited ()
 
 testUnmarkAccredited ()
 
 testSucceed ()
 
 testAllowedTransitionsForInProgress ($status)
 @dataProvider status More...
 
 testAllowedTransitionsForAccredited ($status)
 @dataProvider status More...
 
 testAllowedTransitionsForCompleted ($status)
 @dataProvider status More...
 
 testAllowedTransitionsForFailed ($status)
 @dataProvider status More...
 
 testAllowedTransitionsForIrrelevant ($status)
 @dataProvider status More...
 

Protected Member Functions

 getUserIdAndNow ()
 

Detailed Description

Definition at line 3 of file ilStudyProgrammeProgressTest.php.

Member Function Documentation

◆ getUserIdAndNow()

ilStudyProgrammeProgressTest::getUserIdAndNow ( )
protected

Definition at line 5 of file ilStudyProgrammeProgressTest.php.

5 : array
6 {
7 return [6, new DateTimeImmutable()];
8 }

Referenced by test_completion(), testMarkNotFailed(), and testWithLastChange().

+ Here is the caller graph for this function:

◆ status()

◆ test_amount_of_points()

ilStudyProgrammeProgressTest::test_amount_of_points ( )

@depends test_init_and_id

Definition at line 47 of file ilStudyProgrammeProgressTest.php.

48 {
49 $spp = (new ilStudyProgrammeProgress(123))->withAmountOfPoints(321);
50 $this->assertEquals($spp->getAmountOfPoints(), 321);
51 }
Class ilStudyProgrammeProgress.

◆ test_amount_of_points_invalid()

ilStudyProgrammeProgressTest::test_amount_of_points_invalid ( )

@depends test_init_and_id

Definition at line 56 of file ilStudyProgrammeProgressTest.php.

57 {
58 $this->expectException(\ilException::class);
59 $spp = (new ilStudyProgrammeProgress(123))->withAmountOfPoints(-321);
60 }

◆ test_assignment_date()

ilStudyProgrammeProgressTest::test_assignment_date ( )

@depends test_init_and_id

Definition at line 115 of file ilStudyProgrammeProgressTest.php.

116 {
117 $ad = new DateTimeImmutable();
118 $spp = (new ilStudyProgrammeProgress(123))->withAssignmentDate($ad);
119 $this->assertEquals($spp->getAssignmentDate()->format('Y-m-d'), $ad->format('Y-m-d'));
120 }

◆ test_assignment_id()

ilStudyProgrammeProgressTest::test_assignment_id ( )

@depends test_init_and_id

Definition at line 20 of file ilStudyProgrammeProgressTest.php.

21 {
22 $spp = (new ilStudyProgrammeProgress(123))->withAssignmentId(321);
23 $this->assertEquals($spp->getAssignmentId(), 321);
24 }

◆ test_completion()

ilStudyProgrammeProgressTest::test_completion ( )

@depends test_init_and_id

Definition at line 125 of file ilStudyProgrammeProgressTest.php.

126 {
127 list($acting_usr, $now) = $this->getUserIdAndNow();
128
129 $spp = (new ilStudyProgrammeProgress(123))->withCompletion($acting_usr, $now);
130 $this->assertEquals($now->format('Y-m-d'), $spp->getCompletionDate()->format('Y-m-d'));
131 $this->assertEquals($acting_usr, $spp->getCompletionBy());
132
133 $spp = (new ilStudyProgrammeProgress(123))->withCompletion(null, null);
134 $this->assertNull($spp->getCompletionDate());
135 $this->assertNull($spp->getCompletionBy());
136 }

References getUserIdAndNow().

+ Here is the call graph for this function:

◆ test_current_amount_of_points()

ilStudyProgrammeProgressTest::test_current_amount_of_points ( )

@depends test_init_and_id

Definition at line 65 of file ilStudyProgrammeProgressTest.php.

66 {
67 $spp = (new ilStudyProgrammeProgress(123))->withCurrentAmountOfPoints(321);
68 $this->assertEquals($spp->getCurrentAmountOfPoints(), 321);
69 }

◆ test_deadline()

ilStudyProgrammeProgressTest::test_deadline ( )

@depends test_init_and_id

Definition at line 141 of file ilStudyProgrammeProgressTest.php.

142 {
143 $dl = new DateTimeImmutable();
144 $spp = (new ilStudyProgrammeProgress(123))->withDeadline($dl);
145 $this->assertEquals($spp->getDeadline()->format('Y-m-d'), $dl->format('Y-m-d'));
146 }

◆ test_init_and_id()

ilStudyProgrammeProgressTest::test_init_and_id ( )

Definition at line 10 of file ilStudyProgrammeProgressTest.php.

11 {
12 $spp = new ilStudyProgrammeProgress(123);
13 $this->assertEquals($spp->getId(), 123);
14 return $spp;
15 }

◆ test_invalidate()

ilStudyProgrammeProgressTest::test_invalidate ( )

@depends test_vq_date

Definition at line 172 of file ilStudyProgrammeProgressTest.php.

173 {
174 $spp = new ilStudyProgrammeProgress(123);
175 $this->assertFalse($spp->isInvalidated());
176 $past = DateTimeImmutable::createFromFormat('Ymd', '20180101');
177 $spp = $spp
178 ->withValidityOfQualification($past)
179 ->invalidate();
180 $this->assertTrue($spp->isInvalidated());
181 }

◆ test_invalidate_non_expired_1()

ilStudyProgrammeProgressTest::test_invalidate_non_expired_1 ( )

@depends test_vq_date

Definition at line 186 of file ilStudyProgrammeProgressTest.php.

187 {
188 $this->expectException(\ilException::class);
189 $tomorrow = (new DateTimeImmutable())->add(new DateInterval('P1D'));
190 $spp = (new ilStudyProgrammeProgress(123))->withValidityOfQualification($tomorrow)->invalidate();
191 }
add()
Definition: add.php:2

References add().

+ Here is the call graph for this function:

◆ test_invalidate_non_expired_2()

ilStudyProgrammeProgressTest::test_invalidate_non_expired_2 ( )

@depends test_vq_date

Definition at line 196 of file ilStudyProgrammeProgressTest.php.

197 {
198 $this->expectException(\ilException::class);
199 $spp = (new ilStudyProgrammeProgress(123))->invalidate();
200 }

◆ test_node_id()

ilStudyProgrammeProgressTest::test_node_id ( )

@depends test_init_and_id

Definition at line 29 of file ilStudyProgrammeProgressTest.php.

30 {
31 $spp = (new ilStudyProgrammeProgress(123))->withNodeId(321);
32 $this->assertEquals($spp->getNodeId(), 321);
33 }

◆ test_status()

ilStudyProgrammeProgressTest::test_status (   $status)

@dataProvider status

Definition at line 86 of file ilStudyProgrammeProgressTest.php.

87 {
88 $spp = (new ilStudyProgrammeProgress(123))->withStatus($status);
89 $this->assertEquals($spp->getStatus(), $status);
90 }

◆ test_status_invalid()

ilStudyProgrammeProgressTest::test_status_invalid ( )

@depends test_init_and_id

Definition at line 95 of file ilStudyProgrammeProgressTest.php.

96 {
97 $this->expectException(\ilException::class);
98 $spp = (new ilStudyProgrammeProgress(123))->withStatus(321);
99 }

◆ test_user_id()

ilStudyProgrammeProgressTest::test_user_id ( )

@depends test_init_and_id

Definition at line 38 of file ilStudyProgrammeProgressTest.php.

39 {
40 $spp = (new ilStudyProgrammeProgress(123))->withUserId(321);
41 $this->assertEquals($spp->getUserId(), 321);
42 }

◆ test_vq_date()

ilStudyProgrammeProgressTest::test_vq_date ( )

@depends test_init_and_id

Definition at line 151 of file ilStudyProgrammeProgressTest.php.

152 {
153 $dl = DateTimeImmutable::createFromFormat('Ymd', '20201011');
154 $spp = (new ilStudyProgrammeProgress(123))->withValidityOfQualification($dl);
155 $this->assertEquals($spp->getValidityOfQualification()->format('Ymd'), '20201011');
156 }

◆ testAllowedTransitionsForAccredited()

ilStudyProgrammeProgressTest::testAllowedTransitionsForAccredited (   $status)

@dataProvider status

Definition at line 391 of file ilStudyProgrammeProgressTest.php.

392 {
394 if (in_array($status, [
399 $spp->getStatus()
400 ])) {
401 $this->assertTrue($spp->isTransitionAllowedTo($status));
402 } else {
403 $this->assertFalse($spp->isTransitionAllowedTo($status));
404 }
405 }

References ilStudyProgrammeProgress\STATUS_ACCREDITED, ilStudyProgrammeProgress\STATUS_COMPLETED, ilStudyProgrammeProgress\STATUS_FAILED, ilStudyProgrammeProgress\STATUS_IN_PROGRESS, and ilStudyProgrammeProgress\STATUS_NOT_RELEVANT.

◆ testAllowedTransitionsForCompleted()

ilStudyProgrammeProgressTest::testAllowedTransitionsForCompleted (   $status)

@dataProvider status

Definition at line 410 of file ilStudyProgrammeProgressTest.php.

411 {
413 if (in_array($status, [
415 $spp->getStatus()
416 ])) {
417 $this->assertTrue($spp->isTransitionAllowedTo($status));
418 } else {
419 $this->assertFalse($spp->isTransitionAllowedTo($status));
420 }
421 }

References ilStudyProgrammeProgress\STATUS_COMPLETED, and ilStudyProgrammeProgress\STATUS_IN_PROGRESS.

◆ testAllowedTransitionsForFailed()

ilStudyProgrammeProgressTest::testAllowedTransitionsForFailed (   $status)

@dataProvider status

Definition at line 426 of file ilStudyProgrammeProgressTest.php.

427 {
429 if (in_array($status, [
433 $spp->getStatus()
434 ])) {
435 $this->assertTrue($spp->isTransitionAllowedTo($status));
436 } else {
437 $this->assertFalse($spp->isTransitionAllowedTo($status));
438 }
439 }

References ilStudyProgrammeProgress\STATUS_COMPLETED, ilStudyProgrammeProgress\STATUS_FAILED, ilStudyProgrammeProgress\STATUS_IN_PROGRESS, and ilStudyProgrammeProgress\STATUS_NOT_RELEVANT.

◆ testAllowedTransitionsForInProgress()

ilStudyProgrammeProgressTest::testAllowedTransitionsForInProgress (   $status)

@dataProvider status

Definition at line 372 of file ilStudyProgrammeProgressTest.php.

373 {
375 if (in_array($status, [
380 $spp->getStatus()
381 ])) {
382 $this->assertTrue($spp->isTransitionAllowedTo($status));
383 } else {
384 $this->assertFalse($spp->isTransitionAllowedTo($status));
385 }
386 }

References ilStudyProgrammeProgress\STATUS_ACCREDITED, ilStudyProgrammeProgress\STATUS_COMPLETED, ilStudyProgrammeProgress\STATUS_FAILED, ilStudyProgrammeProgress\STATUS_IN_PROGRESS, and ilStudyProgrammeProgress\STATUS_NOT_RELEVANT.

◆ testAllowedTransitionsForIrrelevant()

ilStudyProgrammeProgressTest::testAllowedTransitionsForIrrelevant (   $status)

@dataProvider status

Definition at line 444 of file ilStudyProgrammeProgressTest.php.

445 {
448 || $status === $spp->getStatus()
449 ) {
450 $this->assertTrue($spp->isTransitionAllowedTo($status));
451 } else {
452 $this->assertFalse($spp->isTransitionAllowedTo($status));
453 }
454 }

References ilStudyProgrammeProgress\STATUS_IN_PROGRESS, and ilStudyProgrammeProgress\STATUS_NOT_RELEVANT.

◆ testHasValidQualification()

ilStudyProgrammeProgressTest::testHasValidQualification ( )

Definition at line 211 of file ilStudyProgrammeProgressTest.php.

212 {
213 $today = new DateTimeImmutable();
214 $yesterday = $today->sub(new DateInterval('P1D'));
215 $tomorrow = $today->add(new DateInterval('P1D'));
216
217 $spp = (new ilStudyProgrammeProgress(123))
219 ->withValidityOfQualification($today);
220
221 $this->assertNull($spp->hasValidQualification($today));
222
223 $spp = $spp->withStatus(ilStudyProgrammeProgress::STATUS_COMPLETED);
224 $this->assertTrue($spp->hasValidQualification($yesterday));
225 $this->assertTrue($spp->hasValidQualification($today));
226 $this->assertFalse($spp->hasValidQualification($tomorrow));
227 }

References ilStudyProgrammeProgress\STATUS_COMPLETED, and ilStudyProgrammeProgress\STATUS_IN_PROGRESS.

◆ testIndividualPlan()

ilStudyProgrammeProgressTest::testIndividualPlan ( ilStudyProgrammeProgress  $spp)

@depends test_init_and_id

Definition at line 161 of file ilStudyProgrammeProgressTest.php.

162 {
163 $this->assertFalse($spp->hasIndividualModifications());
164
165 $this->assertTrue($spp->withIndividualModifications(true)->hasIndividualModifications());
166 $this->assertFalse($spp->withIndividualModifications(false)->hasIndividualModifications());
167 }

References ilStudyProgrammeProgress\hasIndividualModifications(), and ilStudyProgrammeProgress\withIndividualModifications().

+ Here is the call graph for this function:

◆ testIsSuccessful()

ilStudyProgrammeProgressTest::testIsSuccessful (   $status,
  $success 
)

@dataProvider status

Definition at line 205 of file ilStudyProgrammeProgressTest.php.

206 {
207 $spp = (new ilStudyProgrammeProgress(123))->withStatus($status);
208 $this->assertEquals($success, $spp->isSuccessful());
209 }
$success
Definition: Utf8Test.php:86

References $success.

◆ testMarkAccredited()

ilStudyProgrammeProgressTest::testMarkAccredited ( )

Definition at line 308 of file ilStudyProgrammeProgressTest.php.

309 {
310 $usr = 6;
311 $now = new DateTimeImmutable();
312 $spp = (new ilStudyProgrammeProgress(123))
313 ->markAccredited($now, $usr);
314
315 $this->assertEquals($now, $spp->getCompletionDate());
316 $this->assertEquals($usr, $spp->getCompletionBy());
317 $this->assertEquals($usr, $spp->getLastChangeBy());
318 $this->assertEquals(
320 $spp->getLastChange()->format(ilStudyProgrammeProgress::DATE_FORMAT)
321 );
322 $this->assertEquals(
324 $spp->getStatus()
325 );
326 }

References ilStudyProgrammeProgress\DATE_FORMAT, and ilStudyProgrammeProgress\STATUS_ACCREDITED.

◆ testMarkFailed()

ilStudyProgrammeProgressTest::testMarkFailed ( )

Definition at line 269 of file ilStudyProgrammeProgressTest.php.

270 {
271 $usr = 6;
272 $now = new DateTimeImmutable();
273 $spp = (new ilStudyProgrammeProgress(123))
274 ->markFailed($now, $usr);
275
276 $this->assertNull($spp->getCompletionDate());
277 $this->assertNull($spp->getCompletionBy());
278 $this->assertEquals($usr, $spp->getLastChangeBy());
279 $this->assertEquals(
281 $spp->getLastChange()->format(ilStudyProgrammeProgress::DATE_FORMAT)
282 );
283 $this->assertEquals(
285 $spp->getStatus()
286 );
287 }

References ilStudyProgrammeProgress\DATE_FORMAT, and ilStudyProgrammeProgress\STATUS_FAILED.

◆ testMarkNotFailed()

ilStudyProgrammeProgressTest::testMarkNotFailed ( )

Definition at line 289 of file ilStudyProgrammeProgressTest.php.

290 {
291 list($usr, $now) = $this->getUserIdAndNow();
292 $spp = (new ilStudyProgrammeProgress(123))
293 ->markNotFailed($now, $usr);
294
295 $this->assertNull($spp->getCompletionDate());
296 $this->assertNull($spp->getCompletionBy());
297 $this->assertEquals($usr, $spp->getLastChangeBy());
298 $this->assertEquals(
300 $spp->getLastChange()->format(ilStudyProgrammeProgress::DATE_FORMAT)
301 );
302 $this->assertEquals(
304 $spp->getStatus()
305 );
306 }

References ilStudyProgrammeProgress\DATE_FORMAT, getUserIdAndNow(), and ilStudyProgrammeProgress\STATUS_IN_PROGRESS.

+ Here is the call graph for this function:

◆ testMarkNotRelevant()

ilStudyProgrammeProgressTest::testMarkNotRelevant ( )

Definition at line 249 of file ilStudyProgrammeProgressTest.php.

250 {
251 $usr = 6;
252 $now = new DateTimeImmutable();
253 $spp = (new ilStudyProgrammeProgress(123))
254 ->markNotRelevant($now, $usr);
255
256 $this->assertNull($spp->getCompletionBy());
257 $this->assertEquals($usr, $spp->getLastChangeBy());
258 $this->assertEquals(
260 $spp->getLastChange()->format(ilStudyProgrammeProgress::DATE_FORMAT)
261 );
262 $this->assertEquals(
264 $spp->getStatus()
265 );
266 $this->assertTrue($spp->hasIndividualModifications());
267 }

References ilStudyProgrammeProgress\DATE_FORMAT, and ilStudyProgrammeProgress\STATUS_NOT_RELEVANT.

◆ testMarkRelevant()

ilStudyProgrammeProgressTest::testMarkRelevant ( )

Definition at line 229 of file ilStudyProgrammeProgressTest.php.

230 {
231 $usr = 6;
232 $now = new DateTimeImmutable();
233 $spp = (new ilStudyProgrammeProgress(123))
234 ->markRelevant($now, $usr);
235
236 $this->assertNull($spp->getCompletionBy());
237 $this->assertEquals($usr, $spp->getLastChangeBy());
238 $this->assertEquals(
240 $spp->getLastChange()->format(ilStudyProgrammeProgress::DATE_FORMAT)
241 );
242 $this->assertEquals(
244 $spp->getStatus()
245 );
246 $this->assertTrue($spp->hasIndividualModifications());
247 }

References ilStudyProgrammeProgress\DATE_FORMAT, and ilStudyProgrammeProgress\STATUS_IN_PROGRESS.

◆ testSucceed()

ilStudyProgrammeProgressTest::testSucceed ( )

Definition at line 349 of file ilStudyProgrammeProgressTest.php.

350 {
351 $triggering_obj = 777;
352 $now = new DateTimeImmutable();
353 $spp = (new ilStudyProgrammeProgress(123))
354 ->succeed($now, $triggering_obj);
355
356 $this->assertEquals($now, $spp->getCompletionDate());
357 $this->assertEquals($triggering_obj, $spp->getCompletionBy());
358 $this->assertEquals($triggering_obj, $spp->getLastChangeBy());
359 $this->assertEquals(
361 $spp->getLastChange()->format(ilStudyProgrammeProgress::DATE_FORMAT)
362 );
363 $this->assertEquals(
365 $spp->getStatus()
366 );
367 }

References ilStudyProgrammeProgress\DATE_FORMAT, and ilStudyProgrammeProgress\STATUS_COMPLETED.

◆ testUnmarkAccredited()

ilStudyProgrammeProgressTest::testUnmarkAccredited ( )

Definition at line 328 of file ilStudyProgrammeProgressTest.php.

329 {
330 $usr = 6;
331 $now = new DateTimeImmutable();
332 $spp = (new ilStudyProgrammeProgress(123))
333 ->unmarkAccredited($now, $usr);
334
335 $this->assertNull($spp->getCompletionDate());
336 $this->assertNull($spp->getCompletionBy());
337 $this->assertNull($spp->getValidityOfQualification());
338 $this->assertEquals($usr, $spp->getLastChangeBy());
339 $this->assertEquals(
341 $spp->getLastChange()->format(ilStudyProgrammeProgress::DATE_FORMAT)
342 );
343 $this->assertEquals(
345 $spp->getStatus()
346 );
347 }

References ilStudyProgrammeProgress\DATE_FORMAT, and ilStudyProgrammeProgress\STATUS_IN_PROGRESS.

◆ testWithLastChange()

ilStudyProgrammeProgressTest::testWithLastChange ( )

@depends test_init_and_id

Definition at line 104 of file ilStudyProgrammeProgressTest.php.

104 : void
105 {
106 list($acting_usr, $now) = $this->getUserIdAndNow();
107 $spp = (new ilStudyProgrammeProgress(123))->withLastChange($acting_usr, $now);
108 $this->assertEquals($spp->getLastChangeBy(), $acting_usr);
109 $this->assertEquals($spp->getLastChange()->format('Y-m-d H:i:s'), $now->format('Y-m-d H:i:s'));
110 }

References getUserIdAndNow().

+ Here is the call graph for this function:

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