ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilStudyProgrammeAutoMailSettingsTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
26 
28 {
29  private const VALID_SEND_REASSIGNED_MAIL_1 = true;
30  private const VALID_SEND_REASSIGNED_MAIL_2 = false;
37 
38  public function testSuccessfulCreate(): void
39  {
41  self::VALID_SEND_REASSIGNED_MAIL_1,
42  self::VALID_REMINDER_NOT_RESTARTED_BY_USER_1,
43  self::VALID_PROCESSING_ENDS_NOT_SUCCESSFUL_DAYS_1
44  );
45 
46  $this->assertEquals(
47  self::VALID_SEND_REASSIGNED_MAIL_1,
48  $obj->getSendReAssignedMail()
49  );
50 
51  $this->assertEquals(
52  self::VALID_REMINDER_NOT_RESTARTED_BY_USER_1,
53  $obj->getReminderNotRestartedByUserDays()
54  );
55 
56  $this->assertEquals(
57  self::VALID_PROCESSING_ENDS_NOT_SUCCESSFUL_DAYS_1,
58  $obj->getProcessingEndsNotSuccessfulDays()
59  );
60  }
61 
63  {
64  try {
66  self::VALID_SEND_REASSIGNED_MAIL_1,
67  self::INVALID_REMINDER_NOT_RESTARTED_BY_USER,
68  self::VALID_PROCESSING_ENDS_NOT_SUCCESSFUL_DAYS_1
69  );
70  $this->fail();
71  } catch (InvalidArgumentException $e) {
72  $this->assertTrue(true);
73  }
74  }
75 
77  {
78  try {
80  self::VALID_SEND_REASSIGNED_MAIL_1,
81  self::VALID_REMINDER_NOT_RESTARTED_BY_USER_1,
82  self::INVALID_PROCESSING_ENDS_NOT_SUCCESSFUL_DAYS
83  );
84  $this->fail();
85  } catch (InvalidArgumentException $e) {
86  $this->assertTrue(true);
87  }
88  }
89 
90  public function testSuccessfulWithSendReAssignedMail(): void
91  {
93  self::VALID_SEND_REASSIGNED_MAIL_1,
94  self::VALID_REMINDER_NOT_RESTARTED_BY_USER_1,
95  self::VALID_PROCESSING_ENDS_NOT_SUCCESSFUL_DAYS_1
96  );
97 
98  $new = $obj->withSendReAssignedMail(
99  self::VALID_SEND_REASSIGNED_MAIL_2
100  );
101 
102  $this->assertEquals(
103  self::VALID_SEND_REASSIGNED_MAIL_1,
104  $obj->getSendReAssignedMail()
105  );
106 
107  $this->assertEquals(
108  self::VALID_SEND_REASSIGNED_MAIL_2,
109  $new->getSendReAssignedMail()
110  );
111  }
112 
114  {
116  self::VALID_SEND_REASSIGNED_MAIL_1,
117  self::VALID_REMINDER_NOT_RESTARTED_BY_USER_1,
118  self::VALID_PROCESSING_ENDS_NOT_SUCCESSFUL_DAYS_1
119  );
120 
121  $new = $obj->withReminderNotRestartedByUserDays(
122  self::VALID_REMINDER_NOT_RESTARTED_BY_USER_2
123  );
124 
125  $this->assertEquals(
126  self::VALID_REMINDER_NOT_RESTARTED_BY_USER_1,
127  $obj->getReminderNotRestartedByUserDays()
128  );
129 
130  $this->assertEquals(
131  self::VALID_REMINDER_NOT_RESTARTED_BY_USER_2,
132  $new->getReminderNotRestartedByUserDays()
133  );
134  }
135 
137  {
139  self::VALID_SEND_REASSIGNED_MAIL_1,
140  self::VALID_REMINDER_NOT_RESTARTED_BY_USER_1,
141  self::VALID_PROCESSING_ENDS_NOT_SUCCESSFUL_DAYS_1
142  );
143  try {
144  $obj->withReminderNotRestartedByUserDays(self::INVALID_REMINDER_NOT_RESTARTED_BY_USER);
145  $this->fail();
146  } catch (InvalidArgumentException $e) {
147  $this->assertTrue(true);
148  }
149  }
150 
152  {
154  self::VALID_SEND_REASSIGNED_MAIL_1,
155  self::VALID_REMINDER_NOT_RESTARTED_BY_USER_1,
156  self::VALID_PROCESSING_ENDS_NOT_SUCCESSFUL_DAYS_1
157  );
158 
159  $new = $obj->withProcessingEndsNotSuccessfulDays(
160  self::VALID_PROCESSING_ENDS_NOT_SUCCESSFUL_DAYS_2
161  );
162 
163  $this->assertEquals(
164  self::VALID_PROCESSING_ENDS_NOT_SUCCESSFUL_DAYS_1,
165  $obj->getProcessingEndsNotSuccessfulDays()
166  );
167 
168  $this->assertEquals(
169  self::VALID_PROCESSING_ENDS_NOT_SUCCESSFUL_DAYS_2,
170  $new->getProcessingEndsNotSuccessfulDays()
171  );
172  }
173 
175  {
177  self::VALID_SEND_REASSIGNED_MAIL_1,
178  self::VALID_REMINDER_NOT_RESTARTED_BY_USER_1,
179  self::VALID_PROCESSING_ENDS_NOT_SUCCESSFUL_DAYS_1
180  );
181  try {
182  $obj->withProcessingEndsNotSuccessfulDays(
183  self::INVALID_PROCESSING_ENDS_NOT_SUCCESSFUL_DAYS
184  );
185  $this->fail();
186  } catch (InvalidArgumentException $e) {
187  $this->assertTrue(true);
188  }
189  }
190 
191  public function testToFormInput(): void
192  {
193  $lng = $this->createMock(ilLanguage::class);
194  $df = new ILIAS\Data\Factory();
196 
198  $this->createMock(\ILIAS\UI\Implementation\Component\Input\UploadLimitResolver::class),
199  new ILIAS\UI\Implementation\Component\SignalGenerator(),
200  $df,
201  $refinery,
202  $lng
203  );
204 
206  self::VALID_SEND_REASSIGNED_MAIL_1,
207  self::VALID_REMINDER_NOT_RESTARTED_BY_USER_1,
208  self::VALID_PROCESSING_ENDS_NOT_SUCCESSFUL_DAYS_1
209  );
210 
211  $lng->expects($this->atLeastOnce())
212  ->method('txt')
213  ->withConsecutive(
214  ['send_re_assigned_mail'],
215  ['send_re_assigned_mail_info'],
216  ['prg_user_not_restarted_time_input'],
217  ['prg_user_not_restarted_time_input_info'],
218  ['send_info_to_re_assign_mail'],
219  ['send_info_to_re_assign_mail_info'],
220  ['prg_processing_ends_no_success'],
221  ['prg_processing_ends_no_success_info'],
222  ['send_risky_to_fail_mail'],
223  ['send_risky_to_fail_mail_info'],
224  ['prg_cron_job_configuration']
225  )
226  ->will($this->onConsecutiveCalls(
227  'send_re_assigned_mail',
228  'send_re_assigned_mail_info',
229  'prg_user_not_restarted_time_input',
230  'prg_user_not_restarted_time_input_info',
231  'send_info_to_re_assign_mail',
232  'send_info_to_re_assign_mail_info',
233  'prg_processing_ends_no_success',
234  'prg_processing_ends_no_success_info',
235  'send_risky_to_fail_mail',
236  'send_risky_to_fail_mail_info',
237  'prg_cron_job_configuration'
238  ))
239  ;
240 
241  $field = $obj->toFormInput(
242  $f,
243  $lng,
244  $refinery
245  );
246 
247  $this->assertInstanceOf(
248  Section::class,
249  $field
250  );
251 
252  $inputs = $field->getInputs();
253  $cb = $inputs['send_re_assigned_mail'];
254 
256  $og_1 = $inputs['prg_user_not_restarted_time_input'];
257 
259  $og_2 = $inputs['processing_ends_not_success'];
260 
261  $this->assertInstanceOf(
262  Checkbox::class,
263  $cb
264  );
265 
266  $this->assertInstanceOf(
267  OptionalGroup::class,
268  $og_1
269  );
270 
271  $this->assertInstanceOf(
272  OptionalGroup::class,
273  $og_2
274  );
275 
276  $nm_1 = $og_1->getInputs()[0];
277  $nm_2 = $og_2->getInputs()[0];
278 
279  $this->assertInstanceOf(
280  Numeric::class,
281  $nm_1
282  );
283 
284  $this->assertInstanceOf(
285  Numeric::class,
286  $nm_2
287  );
288  }
289 }
Class Factory.
$lng
Class ChatMainBarProvider .
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Refinery Factory $refinery