ILIAS  trunk Revision v11.0_alpha-1689-g66c127b4ae8
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilStudyProgrammeSettingsTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 class ilStudyProgrammeSettingsTest extends \PHPUnit\Framework\TestCase
22 {
23  protected $backupGlobals = false;
24  protected int $id = 123;
26 
27  public function setUp(): void
28  {
29  parent::setUp();
30  $this->prg_settings = new ilStudyProgrammeSettings(
31  $this->id,
32  $this->createMock(ilStudyProgrammeTypeSettings::class),
33  $this->createMock(ilStudyProgrammeAssessmentSettings::class),
34  $this->createMock(ilStudyProgrammeDeadlineSettings::class),
35  $this->createMock(ilStudyProgrammeValidityOfAchievedQualificationSettings::class),
36  $this->createMock(ilStudyProgrammeAutoMailSettings::class)
37  );
38  }
39 
40  public function testPRGSettingsBasicProperties(): void
41  {
42  $this->assertEquals($this->id, $this->prg_settings->getObjId());
43  $this->assertEquals(345, $this->prg_settings->withObjId(345)->getObjId());
44  $this->assertInstanceOf(ilStudyProgrammeSettings::class, $this->prg_settings->updateLastChange());
45  $last_change = new DateTime();
46  $this->assertEquals(
47  $last_change->format(ilStudyProgrammeSettings::DATE_TIME_FORMAT),
48  $this->prg_settings->setLastChange($last_change)->getLastChange()->format(ilStudyProgrammeSettings::DATE_TIME_FORMAT)
49  );
50  }
51  public function testPRGSettingsReturnOfSubSettings(): void
52  {
53  $this->assertInstanceOf(ilStudyProgrammeTypeSettings::class, $this->prg_settings->getTypeSettings());
54  $this->assertInstanceOf(ilStudyProgrammeAssessmentSettings::class, $this->prg_settings->getAssessmentSettings());
55  $this->assertInstanceOf(ilStudyProgrammeDeadlineSettings::class, $this->prg_settings->getDeadlineSettings());
56  $this->assertInstanceOf(ilStudyProgrammeValidityOfAchievedQualificationSettings::class, $this->prg_settings->getValidityOfQualificationSettings());
57  $this->assertInstanceOf(ilStudyProgrammeAutoMailSettings::class, $this->prg_settings->getAutoMailSettings());
58  }
59 
60  public function testPRGSettingsLPMode(): void
61  {
62  $last_change = new DateTime();
63  $prg_settings = $this->prg_settings->setLastChange($last_change);
64  $this->assertEquals(ilStudyProgrammeSettings::MODE_UNDEFINED, $prg_settings->setLPMode(ilStudyProgrammeSettings::MODE_UNDEFINED)->getLPMode());
65  $this->assertEquals(ilStudyProgrammeSettings::MODE_POINTS, $prg_settings->setLPMode(ilStudyProgrammeSettings::MODE_POINTS)->getLPMode());
67  $this->assertNotEquals($last_change, $prg_settings->getLastChange());
68  }
69 
70  public function testPRGSettingsLPModeFails(): void
71  {
72  $this->expectException(\ilException::class);
73  $this->prg_settings->setLPMode(-200);
74  }
75 
76  public function testPRGSettingsValidationExpires(): void
77  {
78  $mock_validity_settings = $this->createMock(ilStudyProgrammeValidityOfAchievedQualificationSettings::class);
79  $mock_validity_settings
80  ->expects($this->once())
81  ->method('getQualificationDate')
82  ->willReturn(new \DateTimeImmutable());
83 
84  $this->assertTrue(
85  $this->prg_settings
86  ->withValidityOfQualificationSettings($mock_validity_settings)
87  ->validationExpires()
88  );
89 
90  $mock_validity_settings = $this->createMock(ilStudyProgrammeValidityOfAchievedQualificationSettings::class);
91  $mock_validity_settings
92  ->expects($this->once())
93  ->method('getQualificationPeriod')
94  ->willReturn(10);
95 
96  $this->assertTrue(
97  $this->prg_settings
98  ->withValidityOfQualificationSettings($mock_validity_settings)
99  ->validationExpires()
100  );
101  $mock_validity_settings = $this->createMock(ilStudyProgrammeValidityOfAchievedQualificationSettings::class);
102  $mock_validity_settings
103  ->expects($this->once())
104  ->method('getQualificationDate')
105  ->willReturn(null);
106  $mock_validity_settings
107  ->expects($this->once())
108  ->method('getQualificationPeriod')
110 
111  $this->assertFalse(
112  $this->prg_settings
113  ->withValidityOfQualificationSettings($mock_validity_settings)
114  ->validationExpires()
115  );
116  }
117 
118 }
setLastChange(DateTime $a_timestamp)
Set the last change timestamp to the given time.
getLastChange()
Get the timestamp of the last change on this program or a sub program.
setLPMode(int $a_mode)
Set the lp mode.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null