ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ilStudyProgrammeAutoMailSettingsTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
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\Field\Node\Factory::class),
199  $this->createMock(\ILIAS\UI\Implementation\Component\Input\UploadLimitResolver::class),
200  new ILIAS\UI\Implementation\Component\SignalGenerator(),
201  $df,
202  $refinery,
203  $lng
204  );
205 
207  self::VALID_SEND_REASSIGNED_MAIL_1,
208  self::VALID_REMINDER_NOT_RESTARTED_BY_USER_1,
209  self::VALID_PROCESSING_ENDS_NOT_SUCCESSFUL_DAYS_1
210  );
211 
212  $lng_consecutive_calls = [];
213  $lng->expects($this->atLeastOnce())
214  ->method('txt')
215  ->willReturnCallback(
216  function ($txt) use (&$lng_consecutive_calls) {
217  $lng_consecutive_calls[] = $txt;
218  return $txt;
219  }
220  );
221 
222  $expected_consecutive_calls = [
223  'send_re_assigned_mail',
224  'send_re_assigned_mail_info',
225  'prg_user_not_restarted_time_input',
226  'prg_user_not_restarted_time_input_info',
227  'send_info_to_re_assign_mail',
228  'send_info_to_re_assign_mail_info',
229  'prg_processing_ends_no_success',
230  'prg_processing_ends_no_success_info',
231  'send_risky_to_fail_mail',
232  'send_risky_to_fail_mail_info',
233  'prg_cron_job_configuration'
234  ];
235 
236  $field = $obj->toFormInput(
237  $f,
238  $lng,
239  $refinery
240  );
241 
242  $this->assertEquals($expected_consecutive_calls, $lng_consecutive_calls);
243 
244  $this->assertInstanceOf(
245  Section::class,
246  $field
247  );
248 
249  $inputs = $field->getInputs();
250  $cb = $inputs['send_re_assigned_mail'];
251 
253  $og_1 = $inputs['prg_user_not_restarted_time_input'];
254 
256  $og_2 = $inputs['processing_ends_not_success'];
257 
258  $this->assertInstanceOf(
259  Checkbox::class,
260  $cb
261  );
262 
263  $this->assertInstanceOf(
264  OptionalGroup::class,
265  $og_1
266  );
267 
268  $this->assertInstanceOf(
269  OptionalGroup::class,
270  $og_2
271  );
272 
273  $nm_1 = $og_1->getInputs()[0];
274  $nm_2 = $og_2->getInputs()[0];
275 
276  $this->assertInstanceOf(
277  Numeric::class,
278  $nm_1
279  );
280 
281  $this->assertInstanceOf(
282  Numeric::class,
283  $nm_2
284  );
285  }
286 }
Interface Observer Contains several chained tasks and infos about them.
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...
$txt
Definition: error.php:31
global $lng
Definition: privfeed.php:31