ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ilStudyProgrammeAssignmentTest.php
Go to the documentation of this file.
1 <?php declare(strict_types=1);
2 
3 require_once(__DIR__ . "/../../../../../libs/composer/vendor/autoload.php");
4 
5 class ilStudyProgrammeAssignmentTest extends \PHPUnit\Framework\TestCase
6 {
7  protected $backupGlobals = false;
8 
10  {
11  $spa = new ilStudyProgrammeAssignment(123);
12  $this->assertEquals($spa->getId(), 123);
13  return $spa;
14  }
15 
19  public function testRootId() : void
20  {
21  $spa = (new ilStudyProgrammeAssignment(123))->withRootId(321);
22  $this->assertEquals($spa->getRootId(), 321);
23  }
24 
28  public function testUserId() : void
29  {
30  $spa = (new ilStudyProgrammeAssignment(123))->withUserId(321);
31  $this->assertEquals($spa->getUserId(), 321);
32  }
33 
37  public function testWithLastChange() : void
38  {
39  $spa = (new ilStudyProgrammeAssignment(123))->withLastChange(
40  6,
41  $now = new DateTimeImmutable()
42  );
43  $this->assertEquals($spa->getLastChangeBy(), 6);
44  $this->assertEquals($spa->getLastChange()->format('Y-m-d H:i:s'), $now->format('Y-m-d H:i:s'));
45  }
46 
47 
51  public function testRestartDate() : void
52  {
53  $dl = DateTimeImmutable::createFromFormat('Ymd', '20201001');
54  $spa = (new ilStudyProgrammeAssignment(123))->withRestarted(321, $dl);
55  $this->assertEquals($spa->getRestartDate()->format('Ymd'), '20201001');
56  $this->assertEquals($spa->getRestartedAssignmentId(), 321);
57  }
58 }
Represents one assignment of the user to a program tree.