ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ilStudyProgrammeAutoMailSettingsTest.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 2019 Daniel Weise <daniel.weise@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4 
5 declare(strict_types=1);
6 
8 
10 {
19 
20  public function testSuccessfulCreate() : void
21  {
23  self::VALID_SEND_REASSIGNED_MAIL_1,
24  self::VALID_REMINDER_NOT_RESTARTED_BY_USER_1,
25  self::VALID_PROCESSING_ENDS_NOT_SUCCESSFUL_DAYS_1
26  );
27 
28  $this->assertEquals(
29  self::VALID_SEND_REASSIGNED_MAIL_1,
30  $obj->getSendReAssignedMail()
31  );
32 
33  $this->assertEquals(
34  self::VALID_REMINDER_NOT_RESTARTED_BY_USER_1,
35  $obj->getReminderNotRestartedByUserDays()
36  );
37 
38  $this->assertEquals(
39  self::VALID_PROCESSING_ENDS_NOT_SUCCESSFUL_DAYS_1,
40  $obj->getProcessingEndsNotSuccessfulDays()
41  );
42  }
43 
45  {
46  try {
48  self::VALID_SEND_REASSIGNED_MAIL_1,
49  self::INVALID_REMINDER_NOT_RESTARTED_BY_USER,
50  self::VALID_PROCESSING_ENDS_NOT_SUCCESSFUL_DAYS_1
51  );
52  $this->assertTrue(false);
53  } catch (InvalidArgumentException $e) {
54  $this->assertTrue(true);
55  }
56  }
57 
59  {
60  try {
62  self::VALID_SEND_REASSIGNED_MAIL_1,
63  self::VALID_REMINDER_NOT_RESTARTED_BY_USER_1,
64  self::INVALID_PROCESSING_ENDS_NOT_SUCCESSFUL_DAYS
65  );
66  $this->assertTrue(false);
67  } catch (InvalidArgumentException $e) {
68  $this->assertTrue(true);
69  }
70  }
71 
72  public function testSuccessfulWithSendReAssignedMail() : void
73  {
75  self::VALID_SEND_REASSIGNED_MAIL_1,
76  self::VALID_REMINDER_NOT_RESTARTED_BY_USER_1,
77  self::VALID_PROCESSING_ENDS_NOT_SUCCESSFUL_DAYS_1
78  );
79 
80  $new = $obj->withSendReAssignedMail(
81  self::VALID_SEND_REASSIGNED_MAIL_2
82  );
83 
84  $this->assertEquals(
85  self::VALID_SEND_REASSIGNED_MAIL_1,
86  $obj->getSendReAssignedMail()
87  );
88 
89  $this->assertEquals(
90  self::VALID_SEND_REASSIGNED_MAIL_2,
91  $new->getSendReAssignedMail()
92  );
93  }
94 
96  {
98  self::VALID_SEND_REASSIGNED_MAIL_1,
99  self::VALID_REMINDER_NOT_RESTARTED_BY_USER_1,
100  self::VALID_PROCESSING_ENDS_NOT_SUCCESSFUL_DAYS_1
101  );
102 
103  $new = $obj->withReminderNotRestartedByUserDays(
104  self::VALID_REMINDER_NOT_RESTARTED_BY_USER_2
105  );
106 
107  $this->assertEquals(
108  self::VALID_REMINDER_NOT_RESTARTED_BY_USER_1,
109  $obj->getReminderNotRestartedByUserDays()
110  );
111 
112  $this->assertEquals(
113  self::VALID_REMINDER_NOT_RESTARTED_BY_USER_2,
114  $new->getReminderNotRestartedByUserDays()
115  );
116  }
117 
119  {
121  self::VALID_SEND_REASSIGNED_MAIL_1,
122  self::VALID_REMINDER_NOT_RESTARTED_BY_USER_1,
123  self::VALID_PROCESSING_ENDS_NOT_SUCCESSFUL_DAYS_1
124  );
125  try {
126  $obj->withReminderNotRestartedByUserDays(self::INVALID_REMINDER_NOT_RESTARTED_BY_USER);
127  $this->assertTrue(false);
128  } catch (InvalidArgumentException $e) {
129  $this->assertTrue(true);
130  }
131  }
132 
134  {
136  self::VALID_SEND_REASSIGNED_MAIL_1,
137  self::VALID_REMINDER_NOT_RESTARTED_BY_USER_1,
138  self::VALID_PROCESSING_ENDS_NOT_SUCCESSFUL_DAYS_1
139  );
140 
141  $new = $obj->withProcessingEndsNotSuccessfulDays(
142  self::VALID_PROCESSING_ENDS_NOT_SUCCESSFUL_DAYS_2
143  );
144 
145  $this->assertEquals(
146  self::VALID_PROCESSING_ENDS_NOT_SUCCESSFUL_DAYS_1,
147  $obj->getProcessingEndsNotSuccessfulDays()
148  );
149 
150  $this->assertEquals(
151  self::VALID_PROCESSING_ENDS_NOT_SUCCESSFUL_DAYS_2,
152  $new->getProcessingEndsNotSuccessfulDays()
153  );
154  }
155 
157  {
159  self::VALID_SEND_REASSIGNED_MAIL_1,
160  self::VALID_REMINDER_NOT_RESTARTED_BY_USER_1,
161  self::VALID_PROCESSING_ENDS_NOT_SUCCESSFUL_DAYS_1
162  );
163  try {
164  $obj->withProcessingEndsNotSuccessfulDays(
165  self::INVALID_PROCESSING_ENDS_NOT_SUCCESSFUL_DAYS
166  );
167  $this->assertTrue(false);
168  } catch (InvalidArgumentException $e) {
169  $this->assertTrue(true);
170  }
171  }
172 
173  public function testToFormInput() : void
174  {
175  $lng = $this->createMock(ilLanguage::class);
176  $df = new ILIAS\Data\Factory();
177  $refinery = new ILIAS\Refinery\Factory($df, $lng);
178 
180  new ILIAS\UI\Implementation\Component\SignalGenerator(),
181  $df,
182  $refinery,
183  $lng
184  );
185 
187  self::VALID_SEND_REASSIGNED_MAIL_1,
188  self::VALID_REMINDER_NOT_RESTARTED_BY_USER_1,
189  self::VALID_PROCESSING_ENDS_NOT_SUCCESSFUL_DAYS_1
190  );
191 
192  $lng->expects($this->atLeastOnce())
193  ->method('txt')
194  ->withConsecutive(
195  ['send_re_assigned_mail'],
196  ['send_re_assigned_mail_info'],
197  ['prg_user_not_restarted_time_input'],
198  ['prg_user_not_restarted_time_input_info'],
199  ['send_info_to_re_assign_mail'],
200  ['send_info_to_re_assign_mail_info'],
201  ['prg_processing_ends_no_success'],
202  ['prg_processing_ends_no_success_info'],
203  ['send_risky_to_fail_mail'],
204  ['send_risky_to_fail_mail_info'],
205  ['prg_cron_job_configuration']
206  )
207  ->will($this->onConsecutiveCalls(
208  'send_re_assigned_mail',
209  'send_re_assigned_mail_info',
210  'prg_user_not_restarted_time_input',
211  'prg_user_not_restarted_time_input_info',
212  'send_info_to_re_assign_mail',
213  'send_info_to_re_assign_mail_info',
214  'prg_processing_ends_no_success',
215  'prg_processing_ends_no_success_info',
216  'send_risky_to_fail_mail',
217  'send_risky_to_fail_mail_info',
218  'prg_cron_job_configuration'
219  ))
220  ;
221 
222  $field = $obj->toFormInput(
223  $f,
224  $lng,
225  $refinery
226  );
227 
228  $this->assertInstanceOf(
229  'ILIAS\UI\Implementation\Component\Input\Field\Section',
230  $field
231  );
232 
233  $inputs = $field->getInputs();
234  $cb = $inputs['send_re_assigned_mail'];
235 
237  $og_1 = $inputs['prg_user_not_restarted_time_input'];
238 
240  $og_2 = $inputs['processing_ends_not_success'];
241 
242  $this->assertInstanceOf(
243  'ILIAS\UI\Implementation\Component\Input\Field\Checkbox',
244  $cb
245  );
246 
247  $this->assertInstanceOf(
248  'ILIAS\UI\Implementation\Component\Input\Field\OptionalGroup',
249  $og_1
250  );
251 
252  $this->assertInstanceOf(
253  'ILIAS\UI\Implementation\Component\Input\Field\OptionalGroup',
254  $og_2
255  );
256 
257  $nm_1 = $og_1->getInputs()[0];
258  $nm_2 = $og_2->getInputs()[0];
259 
260  $this->assertInstanceOf(
261  'ILIAS\UI\Implementation\Component\Input\Field\Numeric',
262  $nm_1
263  );
264 
265  $this->assertInstanceOf(
266  'ILIAS\UI\Implementation\Component\Input\Field\Numeric',
267  $nm_2
268  );
269  }
270 }
Class Factory.
Class ChatMainBarProvider .
$lng
Builds data types.
Definition: Factory.php:19