ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ilStudyProgrammeProgressTest Class Reference
+ Inheritance diagram for ilStudyProgrammeProgressTest:
+ Collaboration diagram for ilStudyProgrammeProgressTest:

Public Member Functions

 test_init_and_id ()
 
 test_assignment_id ()
 test_init_and_id More...
 
 test_node_id ()
 test_init_and_id More...
 
 test_user_id ()
 test_init_and_id More...
 
 test_amount_of_points ()
 test_init_and_id More...
 
 test_amount_of_points_invalid ()
 test_init_and_id More...
 
 test_current_amount_of_points ()
 test_init_and_id More...
 
 status ()
 
 test_status ($status)
 status More...
 
 test_status_invalid ()
 test_init_and_id More...
 
 testWithLastChange ()
 test_init_and_id More...
 
 test_assignment_date ()
 test_init_and_id More...
 
 test_completion ()
 test_init_and_id More...
 
 test_deadline ()
 test_init_and_id More...
 
 test_vq_date ()
 test_init_and_id More...
 
 testIndividualPlan (ilStudyProgrammeProgress $spp)
 test_init_and_id More...
 
 test_invalidate ()
 test_vq_date More...
 
 test_invalidate_non_expired_1 ()
 test_vq_date More...
 
 test_invalidate_non_expired_2 ()
 test_vq_date More...
 
 testIsSuccessful ($status, $success)
 status More...
 
 testHasValidQualification ()
 
 testMarkRelevant ()
 
 testMarkNotRelevant ()
 
 testMarkFailed ()
 
 testMarkNotFailed ()
 
 testMarkAccredited ()
 
 testUnmarkAccredited ()
 
 testSucceed ()
 
 testAllowedTransitionsForInProgress ($status)
 status More...
 
 testAllowedTransitionsForAccredited ($status)
 status More...
 
 testAllowedTransitionsForCompleted ($status)
 status More...
 
 testAllowedTransitionsForFailed ($status)
 status More...
 
 testAllowedTransitionsForIrrelevant ($status)
 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.

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

5  : array
6  {
7  return [6, new DateTimeImmutable()];
8  }
+ Here is the caller graph for this function:

◆ status()

◆ test_amount_of_points()

ilStudyProgrammeProgressTest::test_amount_of_points ( )

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 ( )

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  }
Class ilStudyProgrammeProgress.

◆ test_assignment_date()

ilStudyProgrammeProgressTest::test_assignment_date ( )

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  }
Class ilStudyProgrammeProgress.

◆ test_assignment_id()

ilStudyProgrammeProgressTest::test_assignment_id ( )

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  }
Class ilStudyProgrammeProgress.

◆ test_completion()

ilStudyProgrammeProgressTest::test_completion ( )

test_init_and_id

Definition at line 125 of file ilStudyProgrammeProgressTest.php.

References getUserIdAndNow().

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  }
Class ilStudyProgrammeProgress.
+ Here is the call graph for this function:

◆ test_current_amount_of_points()

ilStudyProgrammeProgressTest::test_current_amount_of_points ( )

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  }
Class ilStudyProgrammeProgress.

◆ test_deadline()

ilStudyProgrammeProgressTest::test_deadline ( )

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  }
Class ilStudyProgrammeProgress.

◆ 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  }
Class ilStudyProgrammeProgress.

◆ test_invalidate()

ilStudyProgrammeProgressTest::test_invalidate ( )

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  }
Class ilStudyProgrammeProgress.

◆ test_invalidate_non_expired_1()

ilStudyProgrammeProgressTest::test_invalidate_non_expired_1 ( )

test_vq_date

Definition at line 186 of file ilStudyProgrammeProgressTest.php.

References add().

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
Class ilStudyProgrammeProgress.
+ Here is the call graph for this function:

◆ test_invalidate_non_expired_2()

ilStudyProgrammeProgressTest::test_invalidate_non_expired_2 ( )

test_vq_date

Definition at line 196 of file ilStudyProgrammeProgressTest.php.

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

◆ test_node_id()

ilStudyProgrammeProgressTest::test_node_id ( )

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  }
Class ilStudyProgrammeProgress.

◆ test_status()

ilStudyProgrammeProgressTest::test_status (   $status)

status

Definition at line 86 of file ilStudyProgrammeProgressTest.php.

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

◆ test_status_invalid()

ilStudyProgrammeProgressTest::test_status_invalid ( )

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  }
Class ilStudyProgrammeProgress.

◆ test_user_id()

ilStudyProgrammeProgressTest::test_user_id ( )

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  }
Class ilStudyProgrammeProgress.

◆ test_vq_date()

ilStudyProgrammeProgressTest::test_vq_date ( )

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  }
Class ilStudyProgrammeProgress.

◆ testAllowedTransitionsForAccredited()

ilStudyProgrammeProgressTest::testAllowedTransitionsForAccredited (   $status)

status

Definition at line 391 of file ilStudyProgrammeProgressTest.php.

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

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  }
Class ilStudyProgrammeProgress.

◆ testAllowedTransitionsForCompleted()

ilStudyProgrammeProgressTest::testAllowedTransitionsForCompleted (   $status)

status

Definition at line 410 of file ilStudyProgrammeProgressTest.php.

References ilStudyProgrammeProgress\STATUS_COMPLETED, and ilStudyProgrammeProgress\STATUS_IN_PROGRESS.

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  }
Class ilStudyProgrammeProgress.

◆ testAllowedTransitionsForFailed()

ilStudyProgrammeProgressTest::testAllowedTransitionsForFailed (   $status)

status

Definition at line 426 of file ilStudyProgrammeProgressTest.php.

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

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  }
Class ilStudyProgrammeProgress.

◆ testAllowedTransitionsForInProgress()

ilStudyProgrammeProgressTest::testAllowedTransitionsForInProgress (   $status)

status

Definition at line 372 of file ilStudyProgrammeProgressTest.php.

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

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  }
Class ilStudyProgrammeProgress.

◆ testAllowedTransitionsForIrrelevant()

ilStudyProgrammeProgressTest::testAllowedTransitionsForIrrelevant (   $status)

status

Definition at line 444 of file ilStudyProgrammeProgressTest.php.

References ilStudyProgrammeProgress\STATUS_IN_PROGRESS, and ilStudyProgrammeProgress\STATUS_NOT_RELEVANT.

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

◆ testHasValidQualification()

ilStudyProgrammeProgressTest::testHasValidQualification ( )

Definition at line 211 of file ilStudyProgrammeProgressTest.php.

References ilStudyProgrammeProgress\STATUS_COMPLETED, and ilStudyProgrammeProgress\STATUS_IN_PROGRESS.

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  }
Class ilStudyProgrammeProgress.

◆ testIndividualPlan()

ilStudyProgrammeProgressTest::testIndividualPlan ( ilStudyProgrammeProgress  $spp)

test_init_and_id

Definition at line 161 of file ilStudyProgrammeProgressTest.php.

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

162  {
163  $this->assertFalse($spp->hasIndividualModifications());
164 
165  $this->assertTrue($spp->withIndividualModifications(true)->hasIndividualModifications());
166  $this->assertFalse($spp->withIndividualModifications(false)->hasIndividualModifications());
167  }
+ Here is the call graph for this function:

◆ testIsSuccessful()

ilStudyProgrammeProgressTest::testIsSuccessful (   $status,
  $success 
)

status

Definition at line 205 of file ilStudyProgrammeProgressTest.php.

References $success.

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

◆ testMarkAccredited()

ilStudyProgrammeProgressTest::testMarkAccredited ( )

Definition at line 308 of file ilStudyProgrammeProgressTest.php.

References ilStudyProgrammeProgress\DATE_FORMAT, and ilStudyProgrammeProgress\STATUS_ACCREDITED.

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  }
Class ilStudyProgrammeProgress.

◆ testMarkFailed()

ilStudyProgrammeProgressTest::testMarkFailed ( )

Definition at line 269 of file ilStudyProgrammeProgressTest.php.

References ilStudyProgrammeProgress\DATE_FORMAT, and ilStudyProgrammeProgress\STATUS_FAILED.

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  }
Class ilStudyProgrammeProgress.

◆ testMarkNotFailed()

ilStudyProgrammeProgressTest::testMarkNotFailed ( )

Definition at line 289 of file ilStudyProgrammeProgressTest.php.

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

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  }
Class ilStudyProgrammeProgress.
+ Here is the call graph for this function:

◆ testMarkNotRelevant()

ilStudyProgrammeProgressTest::testMarkNotRelevant ( )

Definition at line 249 of file ilStudyProgrammeProgressTest.php.

References ilStudyProgrammeProgress\DATE_FORMAT, and ilStudyProgrammeProgress\STATUS_NOT_RELEVANT.

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  }
Class ilStudyProgrammeProgress.

◆ testMarkRelevant()

ilStudyProgrammeProgressTest::testMarkRelevant ( )

Definition at line 229 of file ilStudyProgrammeProgressTest.php.

References ilStudyProgrammeProgress\DATE_FORMAT, and ilStudyProgrammeProgress\STATUS_IN_PROGRESS.

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  }
Class ilStudyProgrammeProgress.

◆ testSucceed()

ilStudyProgrammeProgressTest::testSucceed ( )

Definition at line 349 of file ilStudyProgrammeProgressTest.php.

References ilStudyProgrammeProgress\DATE_FORMAT, and ilStudyProgrammeProgress\STATUS_COMPLETED.

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  }
Class ilStudyProgrammeProgress.

◆ testUnmarkAccredited()

ilStudyProgrammeProgressTest::testUnmarkAccredited ( )

Definition at line 328 of file ilStudyProgrammeProgressTest.php.

References ilStudyProgrammeProgress\DATE_FORMAT, and ilStudyProgrammeProgress\STATUS_IN_PROGRESS.

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  }
Class ilStudyProgrammeProgress.

◆ testWithLastChange()

ilStudyProgrammeProgressTest::testWithLastChange ( )

test_init_and_id

Definition at line 104 of file ilStudyProgrammeProgressTest.php.

References getUserIdAndNow().

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  }
Class ilStudyProgrammeProgress.
+ Here is the call graph for this function:

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