ILIAS  trunk Revision v11.0_alpha-1689-g66c127b4ae8
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilStudyProgrammeSubSettingsTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
27 
36 class ilStudyProgrammeSubSettingsTest extends \PHPUnit\Framework\TestCase
37 {
38  protected ilLanguage $lng;
39  protected Refinery $refinery;
42 
43  public function setUp(): void
44  {
45  $this->data_factory = new DataFactory();
46  $this->lng = $this->createMock(ilLanguage::class);
47  $this->refinery = new Refinery($this->data_factory, $this->lng);
48  $this->field_factory = new FieldFactory(
49  $this->createMock(UploadLimitResolver::class),
50  new SignalGenerator(),
51  $this->data_factory,
52  $this->refinery,
53  $this->lng
54  );
55  }
56 
57  public function testPRGSettingsType(): void
58  {
59  $settings = new ilStudyProgrammeTypeSettings(765);
60  $this->assertEquals(765, $settings->getTypeId());
61  $this->assertEquals(777, $settings->withTypeId(777)->getTypeId());
62  }
63 
64  public function testPRGSettingsTypeToForm(): void
65  {
66  $settings = new ilStudyProgrammeTypeSettings(0);
67  $section = $settings->toFormInput(
68  $this->field_factory,
69  $this->lng,
70  $this->refinery,
71  [3 => 'AA', 7 => 'BB']
72  );
73  $this->assertInstanceOf(Field\Section::class, $section);
74  $inputs = $section->getInputs();
75  $this->assertInstanceOf(Field\Select::class, array_shift($inputs));
76  }
77 
78  public function testPRGSettingsAssessment(): void
79  {
81  $this->assertEquals(12, $settings->getPoints());
82  $this->assertEquals(13, $settings->withPoints(13)->getPoints());
83  $this->assertEquals(ilStudyProgrammeAssessmentSettings::STATUS_DRAFT, $settings->getStatus());
84  $this->assertEquals(
86  $settings->withStatus(ilStudyProgrammeAssessmentSettings::STATUS_ACTIVE)->getStatus()
87  );
88  }
89 
90  public function testPRGSettingsAssessmentToForm(): void
91  {
93  $section = $settings->toFormInput(
94  $this->field_factory,
95  $this->lng,
96  $this->refinery
97  );
98  $this->assertInstanceOf(Field\Section::class, $section);
99  $inputs = $section->getInputs();
100  $this->assertInstanceOf(Field\Numeric::class, array_shift($inputs));
101  $this->assertInstanceOf(Field\Select::class, array_shift($inputs));
102  }
103 
104  public function testPRGSettingsDeadline(): void
105  {
106  $settings = new ilStudyProgrammeDeadlineSettings(2, null);
107  $this->assertEquals(2, $settings->getDeadlinePeriod());
108  $this->assertEquals(13, $settings->withDeadlinePeriod(13)->getDeadlinePeriod());
109  $this->assertNull($settings->getDeadlineDate());
110  $dat = new \DateTimeImmutable();
111  $this->assertEquals($dat, $settings->withDeadlineDate($dat)->getDeadlineDate());
112  }
113 
114  public function testPRGSettingsDeadlineToForm(): void
115  {
116  $settings = new ilStudyProgrammeDeadlineSettings(null, null);
117  $section = $settings->toFormInput(
118  $this->field_factory,
119  $this->lng,
120  $this->refinery,
121  $this->data_factory
122  );
123  $this->assertInstanceOf(Field\Section::class, $section);
124  $group = $section->getInputs();
125  $this->assertInstanceOf(Field\SwitchableGroup::class, current($group));
126  $inputs = current($group)->getInputs();
127  $group1 = array_shift($inputs);
128  $this->assertEquals([], $group1->getInputs());
129  $group2 = array_shift($inputs);
130  $g_inputs = $group2->getInputs();
131  $this->assertInstanceOf(Field\Numeric::class, array_shift($g_inputs));
132  $group3 = array_shift($inputs);
133  $g_inputs = $group3->getInputs();
134  $this->assertInstanceOf(Field\DateTime::class, array_shift($g_inputs));
135  }
136 
137  public function testPRGSettingsValidity(): void
138  {
140  $this->assertEquals(365, $settings->withQualificationPeriod(365)->getQualificationPeriod());
141  $dat = new \DateTimeImmutable();
142  $this->assertEquals($dat, $settings->withQualificationDate($dat)->getQualificationDate());
143  $this->assertEquals(31, $settings->withRestartPeriod(31)->getRestartPeriod());
144  }
145 
146  public function testPRGSettingsValidityToForm(): void
147  {
149  $section = $settings->toFormInput(
150  $this->field_factory,
151  $this->lng,
152  $this->refinery,
153  $this->data_factory
154  );
155  $this->assertInstanceOf(Field\Section::class, $section);
156 
157  $groups = $section->getInputs();
158  $sg1 = array_shift($groups);
159  $this->assertInstanceOf(Field\SwitchableGroup::class, $sg1);
160  $sg2 = array_shift($groups);
161  $this->assertInstanceOf(Field\SwitchableGroup::class, $sg1);
162 
163  $inputs = $sg1->getInputs();
164  $group1 = array_shift($inputs);
165  $this->assertEquals([], $group1->getInputs());
166  $group2 = array_shift($inputs);
167  $g_inputs = $group2->getInputs();
168  $this->assertInstanceOf(Field\Numeric::class, array_shift($g_inputs));
169  $group3 = array_shift($inputs);
170  $g_inputs = $group3->getInputs();
171  $this->assertInstanceOf(Field\DateTime::class, array_shift($g_inputs));
172 
173  $inputs = $sg2->getInputs();
174  $group4 = array_shift($inputs);
175  $this->assertEquals([], $group4->getInputs());
176  $group5 = array_shift($inputs);
177  $g5_inputs = $group5->getInputs();
178  $this->assertInstanceOf(Field\Numeric::class, array_shift($g5_inputs));
179  $this->assertInstanceOf(Field\Checkbox::class, array_shift($g5_inputs));
180  }
181 
182  public function testPRGSettingsMail(): void
183  {
184  $settings = new ilStudyProgrammeAutoMailSettings(false, null, null);
185  $this->assertTrue($settings->withSendReAssignedMail(true)->getSendReAssignedMail());
186  $this->assertEquals(31, $settings->withReminderNotRestartedByUserDays(31)->getReminderNotRestartedByUserDays());
187  $this->assertEquals(60, $settings->withProcessingEndsNotSuccessfulDays(60)->getProcessingEndsNotSuccessfulDays());
188  }
189 
190  public function testPRGSettingsMailToForm(): void
191  {
192  $settings = new ilStudyProgrammeAutoMailSettings(false, null, null);
193  $section = $settings->toFormInput(
194  $this->field_factory,
195  $this->lng,
196  $this->refinery
197  );
198  $this->assertInstanceOf(Field\Section::class, $section);
199  $inputs = $section->getInputs();
200  $this->assertInstanceOf(Field\Checkbox::class, array_shift($inputs));
201  $opt = array_shift($inputs);
202  $this->assertInstanceOf(Field\OptionalGroup::class, $opt);
203  $g_inputs = $opt->getInputs();
204  $this->assertInstanceOf(Field\Numeric::class, array_shift($g_inputs));
205  $opt = array_shift($inputs);
206  $this->assertInstanceOf(Field\OptionalGroup::class, $opt);
207  $g_inputs = $opt->getInputs();
208  $this->assertInstanceOf(Field\Numeric::class, array_shift($g_inputs));
209  }
210 }
Tests for: ilStudyProgrammeTypeSettings ilStudyProgrammeAssessmentSettings ilStudyProgrammeDeadlineSe...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Checkbox.php:21
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...