ILIAS  trunk Revision v11.0_alpha-1689-g66c127b4ae8
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilStudyProgrammeSettingsRepositoryTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 class ilStudyProgrammeSettingsRepositoryTest extends \PHPUnit\Framework\TestCase
22 {
23  protected static $created;
24  protected ilDBInterface $db;
26 
27  protected function setUp(): void
28  {
29  $this->db = $this->createMock(ilDBInterface::class);
30  $this->tps = $this->createMock(ilOrgUnitObjectTypePositionSetting::class);
31  $this->tps->method('getActivationDefault')
32  ->willReturn(1);
33  }
34 
36  {
38  $this->db,
39  $this->tps
40  );
41  $this->assertInstanceOf(ilStudyProgrammeSettingsRepository::class, $repo);
42  return $repo;
43  }
44 
49  {
50  $this->markTestSkipped('Failed for some unknown reason.');
51 
53  $this->db,
54  $this->tps
55  );
56  $set = $repo->createFor(-1);
57  $this->assertEquals($set->getTypeSettings()->getTypeId(), ilStudyProgrammeSettings::DEFAULT_SUBTYPE);
58  $this->assertEquals($set->getAssessmentSettings()->getStatus(), ilStudyProgrammeSettings::STATUS_DRAFT);
59  $this->assertEquals($set->getLPMode(), ilStudyProgrammeSettings::MODE_UNDEFINED);
60  $this->assertEquals($set->getAssessmentSettings()->getPoints(), ilStudyProgrammeSettings::DEFAULT_POINTS);
61  $this->assertEquals($set->getDeadlineSettings()->getDeadlinePeriod(), 0);
62  $this->assertNull($set->getDeadlineSettings()->getDeadlineDate());
63  $this->assertEquals($set->getValidityOfQualificationSettings()->getQualificationPeriod(), ilStudyProgrammeSettings::NO_VALIDITY_OF_QUALIFICATION_PERIOD);
64  $this->assertNull($set->getValidityOfQualificationSettings()->getQualificationDate());
65  $this->assertEquals($set->getValidityOfQualificationSettings()->getRestartPeriod(), ilStudyProgrammeSettings::NO_RESTART);
66 
68  $this->db,
69  $this->tps
70  );
72  $set = $repo->get(-1);
73  $this->assertEquals($set->getSubtypeId(), ilStudyProgrammeSettings::DEFAULT_SUBTYPE);
74  $this->assertEquals($set->getAssessmentSettings()->getStatus(), ilStudyProgrammeSettings::STATUS_DRAFT);
75  $this->assertEquals($set->getLPMode(), ilStudyProgrammeSettings::MODE_UNDEFINED);
76  $this->assertEquals($set->getPoints(), ilStudyProgrammeSettings::DEFAULT_POINTS);
77  $this->assertEquals($set->getDeadlinePeriod(), 0);
78  $this->assertNull($set->getDeadlineDate());
79  $this->assertEquals($set->getValidityOfQualificationPeriod(), ilStudyProgrammeSettings::NO_VALIDITY_OF_QUALIFICATION_PERIOD);
80  $this->assertNull($set->getValidityOfQualificationDate());
81  $this->assertEquals($set->getRestartPeriod(), ilStudyProgrammeSettings::NO_RESTART);
82 
83  $set->setSubtypeId(123)
86  ->setPoints(10)
87  ->setDeadlinePeriod(10)
88  ->setValidityOfQualificationPeriod(20)
89  ->setRestartPeriod(30);
90  $repo->update($set);
92  $set = $repo->get(-1);
93  $this->assertEquals($set->getSubtypeId(), 123);
94  $this->assertEquals($set->getStatus(), ilStudyProgrammeSettings::STATUS_ACTIVE);
95  $this->assertEquals($set->getLPMode(), ilStudyProgrammeSettings::MODE_POINTS);
96  $this->assertEquals($set->getPoints(), 10);
97  $this->assertEquals($set->getDeadlinePeriod(), 10);
98  $this->assertNull($set->getDeadlineDate());
99  $this->assertEquals($set->getValidityOfQualificationPeriod(), 20);
100  $this->assertNull($set->getValidityOfQualificationDate());
101  $this->assertEquals($set->getRestartPeriod(), 30);
102 
103  $set->setSubtypeId(123)
104  ->setDeadlineDate(new DateTime())
105  ->setValidityOfQualificationDate(DateTime::createFromFormat('Ymd', '20200101'))
106  ->setRestartPeriod(ilStudyProgrammeSettings::NO_RESTART);
107  $repo->update($set);
109  $set = $repo->get(-1);
110  $this->assertEquals($set->getDeadlinePeriod(), 0);
111  $this->assertEquals($set->getDeadlineDate()->format('Ymd'), (new DateTime())->format('Ymd'));
112  $this->assertEquals($set->getValidityOfQualificationDate()->format('Ymd'), '20200101');
113  $this->assertEquals($set->getValidityOfQualificationPeriod(), ilStudyProgrammeSettings::NO_VALIDITY_OF_QUALIFICATION_PERIOD);
114  $this->assertEquals($set->getRestartPeriod(), ilStudyProgrammeSettings::NO_RESTART);
115 
117  $this->db,
118  $this->tps
119  );
121  $set = $repo->get(-1);
122  $this->assertEquals($set->getSubtypeId(), 123);
123  $this->assertEquals($set->getStatus(), ilStudyProgrammeSettings::STATUS_ACTIVE);
124  $this->assertEquals($set->getLPMode(), ilStudyProgrammeSettings::MODE_POINTS);
125  $this->assertEquals($set->getPoints(), 10);
126  }
127 
131  public function testPRGRepoDelete()
132  {
133  $this->expectException(\LogicException::class);
135  $this->db,
136  $this->tps
137  );
138  $set = $repo->get(-1);
139  $this->assertEquals($set->getSubtypeId(), 123);
140  $this->assertEquals($set->getStatus(), ilStudyProgrammeSettings::STATUS_ACTIVE);
141  $this->assertEquals($set->getLPMode(), ilStudyProgrammeSettings::MODE_POINTS);
142  $this->assertEquals($set->getPoints(), 10);
143  $repo->delete($set);
144  $repo->get(-1);
145  }
146 }
createFor(int $obj_id)
Create a record corresponding to a SP-Object and return representing settings.Will throw if a record ...
testPRGRepoEditAndUpdate(ilStudyProgrammeSettingsDBRepository $repo)
test_init
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...