ILIAS  trunk Revision v11.0_alpha-1689-g66c127b4ae8
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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\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_consecutive_calls = [];
212  $lng->expects($this->atLeastOnce())
213  ->method('txt')
214  ->willReturnCallback(
215  function ($txt) use (&$lng_consecutive_calls) {
216  $lng_consecutive_calls[] = $txt;
217  return $txt;
218  }
219  );
220 
221  $expected_consecutive_calls = [
222  'send_re_assigned_mail',
223  'send_re_assigned_mail_info',
224  'prg_user_not_restarted_time_input',
225  'prg_user_not_restarted_time_input_info',
226  'send_info_to_re_assign_mail',
227  'send_info_to_re_assign_mail_info',
228  'prg_processing_ends_no_success',
229  'prg_processing_ends_no_success_info',
230  'send_risky_to_fail_mail',
231  'send_risky_to_fail_mail_info',
232  'prg_cron_job_configuration'
233  ];
234 
235  $field = $obj->toFormInput(
236  $f,
237  $lng,
238  $refinery
239  );
240 
241  $this->assertEquals($expected_consecutive_calls, $lng_consecutive_calls);
242 
243  $this->assertInstanceOf(
244  Section::class,
245  $field
246  );
247 
248  $inputs = $field->getInputs();
249  $cb = $inputs['send_re_assigned_mail'];
250 
252  $og_1 = $inputs['prg_user_not_restarted_time_input'];
253 
255  $og_2 = $inputs['processing_ends_not_success'];
256 
257  $this->assertInstanceOf(
258  Checkbox::class,
259  $cb
260  );
261 
262  $this->assertInstanceOf(
263  OptionalGroup::class,
264  $og_1
265  );
266 
267  $this->assertInstanceOf(
268  OptionalGroup::class,
269  $og_2
270  );
271 
272  $nm_1 = $og_1->getInputs()[0];
273  $nm_2 = $og_2->getInputs()[0];
274 
275  $this->assertInstanceOf(
276  Numeric::class,
277  $nm_1
278  );
279 
280  $this->assertInstanceOf(
281  Numeric::class,
282  $nm_2
283  );
284  }
285 }
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