ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
ilCalendarRecurrenceCalculationTest Class Reference
+ Inheritance diagram for ilCalendarRecurrenceCalculationTest:
+ Collaboration diagram for ilCalendarRecurrenceCalculationTest:

Public Member Functions

 testCalculatorConstruct ()
 
 testYearly ()
 
 testYearlyByDay ()
 
 testMonthly ()
 
 testMonthlyByDay ()
 
 testWeekly ()
 
 testWeeklyByDay ()
 
 testDaily ()
 
 testUntilEndDateInclusive ()
 

Protected Member Functions

 setUp ()
 
 setGlobalVariable (string $name, $value)
 
 initDependencies ()
 

Protected Attributes

 $backupGlobals = false
 
Container $dic
 

Detailed Description

Definition at line 24 of file ilCalendarRecurrenceCalculationTest.php.

Member Function Documentation

◆ initDependencies()

ilCalendarRecurrenceCalculationTest::initDependencies ( )
protected

Definition at line 296 of file ilCalendarRecurrenceCalculationTest.php.

References $dic, $GLOBALS, and setGlobalVariable().

Referenced by setUp().

296  : void
297  {
298  $this->dic = new Container();
299  $GLOBALS['DIC'] = $this->dic;
300 
301  $this->setGlobalVariable('ilDB', $this->createMock(ilDBInterface::class));
302  $this->setGlobalVariable('lng', $this->createMock(ilLanguage::class));
303  $this->setGlobalVariable('ilErr', $this->createMock(ilErrorHandling::class));
304 
305  $logger = $this->getMockBuilder(ilLogger::class)
306  ->disableOriginalConstructor()
307  ->getMock();
308 
309  $logger_factory = $this->getMockBuilder(ilLoggerFactory::class)
310  ->disableOriginalConstructor()
311  ->onlyMethods(['getComponentLogger'])
312  ->getMock();
313  $logger_factory->method('getComponentLogger')->willReturn($logger);
314  $this->setGlobalVariable('ilLoggerFactory', $logger_factory);
315  }
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:35
$GLOBALS["DIC"]
Definition: wac.php:54
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setGlobalVariable()

ilCalendarRecurrenceCalculationTest::setGlobalVariable ( string  $name,
  $value 
)
protected

Definition at line 285 of file ilCalendarRecurrenceCalculationTest.php.

References $c, $DIC, and $GLOBALS.

Referenced by initDependencies().

285  : void
286  {
287  global $DIC;
288 
289  $GLOBALS[$name] = $value;
290  unset($DIC[$name]);
291  $DIC[$name] = static function (\ILIAS\DI\Container $c) use ($value) {
292  return $value;
293  };
294  }
$c
Definition: deliver.php:25
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:35
$GLOBALS["DIC"]
Definition: wac.php:54
global $DIC
Definition: shib_login.php:26
+ Here is the caller graph for this function:

◆ setUp()

ilCalendarRecurrenceCalculationTest::setUp ( )
protected

Definition at line 29 of file ilCalendarRecurrenceCalculationTest.php.

References initDependencies().

29  : void
30  {
31  $this->initDependencies();
32  parent::setUp();
33  }
+ Here is the call graph for this function:

◆ testCalculatorConstruct()

ilCalendarRecurrenceCalculationTest::testCalculatorConstruct ( )

Definition at line 35 of file ilCalendarRecurrenceCalculationTest.php.

References IL_CAL_DATE.

35  : void
36  {
37  $entry = new ilCalendarEntry(0);
38  $entry->setStart(new ilDate('2022-01-01', IL_CAL_DATE));
39  $entry->setEnd(new ilDate('2022-01-01', IL_CAL_DATE));
40  $entry->setFullday(true);
41  $entry->setTitle('First');
42  $rec = new ilCalendarRecurrence(0);
43 
45  $entry,
46  $rec
47  );
48  $this->assertInstanceOf(ilCalendarRecurrenceCalculator::class, $calc);
49  }
Calculates an ilDateList for a given calendar entry and recurrence rule.
const IL_CAL_DATE

◆ testDaily()

ilCalendarRecurrenceCalculationTest::testDaily ( )

Definition at line 229 of file ilCalendarRecurrenceCalculationTest.php.

References ilCalendarRecurrence\FREQ_DAILY, IL_CAL_DATE, and ilDateList\TYPE_DATE.

229  : void
230  {
231  $entry = new ilCalendarEntry(0);
232  $entry->setStart(new ilDate('2022-01-01', IL_CAL_DATE));
233  $entry->setEnd(new ilDate('2022-01-01', IL_CAL_DATE));
234  $entry->setFullday(true);
235 
236  $rec = new ilCalendarRecurrence(0);
237  $rec->setFrequenceType(ilCalendarRecurrence::FREQ_DAILY);
238  $rec->setInterval(1);
239  $rec->setFrequenceUntilCount(2);
240 
241  $calc = new ilCalendarRecurrenceCalculator(
242  $entry,
243  $rec
244  );
245  $dl = $calc->calculateDateList(
246  new ilDateTime('2021-12-31', IL_CAL_DATE),
247  new ilDate('2023-12-31', IL_CAL_DATE),
248  -1
249  );
250  $result = new ilDateList(ilDateList::TYPE_DATE);
251  $result->add(new ilDate('2022-01-01', IL_CAL_DATE));
252  $result->add(new ilDate('2022-01-02', IL_CAL_DATE));
253 
254  $this->assertTrue($result == $dl);
255  }
Calculates an ilDateList for a given calendar entry and recurrence rule.
List of dates.
const IL_CAL_DATE

◆ testMonthly()

ilCalendarRecurrenceCalculationTest::testMonthly ( )

Definition at line 113 of file ilCalendarRecurrenceCalculationTest.php.

References ilCalendarRecurrence\FREQ_MONTHLY, IL_CAL_DATE, and ilDateList\TYPE_DATE.

114  {
115  $entry = new ilCalendarEntry(0);
116  $entry->setStart(new ilDate('2022-01-01', IL_CAL_DATE));
117  $entry->setEnd(new ilDate('2022-01-01', IL_CAL_DATE));
118  $entry->setFullday(true);
119 
120  $rec = new ilCalendarRecurrence(0);
121  $rec->setFrequenceType(ilCalendarRecurrence::FREQ_MONTHLY);
122  $rec->setInterval(1);
123  $rec->setFrequenceUntilCount(2);
124 
125  $calc = new ilCalendarRecurrenceCalculator(
126  $entry,
127  $rec
128  );
129  $dl = $calc->calculateDateList(
130  new ilDateTime('2021-12-31', IL_CAL_DATE),
131  new ilDate('2023-12-31', IL_CAL_DATE),
132  -1
133  );
134  $result = new ilDateList(ilDateList::TYPE_DATE);
135  $result->add(new ilDate('2022-01-01', IL_CAL_DATE));
136  $result->add(new ilDate('2022-02-01', IL_CAL_DATE));
137 
138  $this->assertTrue($result == $dl);
139  }
Calculates an ilDateList for a given calendar entry and recurrence rule.
List of dates.
const IL_CAL_DATE

◆ testMonthlyByDay()

ilCalendarRecurrenceCalculationTest::testMonthlyByDay ( )

Definition at line 141 of file ilCalendarRecurrenceCalculationTest.php.

References ilCalendarRecurrence\FREQ_MONTHLY, IL_CAL_DATE, and ilDateList\TYPE_DATE.

142  {
143  $entry = new ilCalendarEntry(0);
144  $entry->setStart(new ilDate('2022-01-01', IL_CAL_DATE));
145  $entry->setEnd(new ilDate('2022-01-01', IL_CAL_DATE));
146  $entry->setFullday(true);
147 
148  // next two first days of the month which are on saturday => (2022-01-01, 2022-10-01)
149  $rec = new ilCalendarRecurrence(0);
150  $rec->setFrequenceType(ilCalendarRecurrence::FREQ_MONTHLY);
151  $rec->setBYDAY('SA');
152  $rec->setBYMONTHDAY('1');
153  $rec->setInterval(1);
154  $rec->setFrequenceUntilCount(2);
155 
156  $calc = new ilCalendarRecurrenceCalculator(
157  $entry,
158  $rec
159  );
160  $dl = $calc->calculateDateList(
161  new ilDateTime('2021-12-31', IL_CAL_DATE),
162  new ilDate('2023-12-31', IL_CAL_DATE),
163  -1
164  );
165  $result = new ilDateList(ilDateList::TYPE_DATE);
166  $result->add(new ilDate('2022-01-01', IL_CAL_DATE));
167  $result->add(new ilDate('2022-10-01', IL_CAL_DATE));
168  $this->assertTrue($result == $dl);
169  }
Calculates an ilDateList for a given calendar entry and recurrence rule.
List of dates.
const IL_CAL_DATE

◆ testUntilEndDateInclusive()

ilCalendarRecurrenceCalculationTest::testUntilEndDateInclusive ( )

Definition at line 257 of file ilCalendarRecurrenceCalculationTest.php.

References ilCalendarRecurrence\FREQ_DAILY, IL_CAL_DATE, and ilDateList\TYPE_DATE.

257  : void
258  {
259  $entry = new ilCalendarEntry(0);
260  $entry->setStart(new ilDate('2022-01-01', IL_CAL_DATE));
261  $entry->setEnd(new ilDate('2022-01-01', IL_CAL_DATE));
262  $entry->setFullday(true);
263 
264  $rec = new ilCalendarRecurrence(0);
265  $rec->setFrequenceType(ilCalendarRecurrence::FREQ_DAILY);
266  $rec->setInterval(1);
267  $rec->setFrequenceUntilDate(new ilDate('2022-01-02', IL_CAL_DATE));
268 
269  $calc = new ilCalendarRecurrenceCalculator(
270  $entry,
271  $rec
272  );
273  $dl = $calc->calculateDateList(
274  new ilDateTime('2021-12-31', IL_CAL_DATE),
275  new ilDate('2023-12-31', IL_CAL_DATE),
276  -1
277  );
278  $result = new ilDateList(ilDateList::TYPE_DATE);
279  $result->add(new ilDate('2022-01-01', IL_CAL_DATE));
280  $result->add(new ilDate('2022-01-02', IL_CAL_DATE));
281 
282  $this->assertTrue($result == $dl);
283  }
Calculates an ilDateList for a given calendar entry and recurrence rule.
List of dates.
const IL_CAL_DATE

◆ testWeekly()

ilCalendarRecurrenceCalculationTest::testWeekly ( )

Definition at line 171 of file ilCalendarRecurrenceCalculationTest.php.

References ilCalendarRecurrence\FREQ_WEEKLY, IL_CAL_DATE, and ilDateList\TYPE_DATE.

171  : void
172  {
173  $entry = new ilCalendarEntry(0);
174  $entry->setStart(new ilDate('2022-01-01', IL_CAL_DATE));
175  $entry->setEnd(new ilDate('2022-01-01', IL_CAL_DATE));
176  $entry->setFullday(true);
177 
178  $rec = new ilCalendarRecurrence(0);
179  $rec->setFrequenceType(ilCalendarRecurrence::FREQ_WEEKLY);
180  $rec->setInterval(1);
181  $rec->setFrequenceUntilCount(2);
182 
183  $calc = new ilCalendarRecurrenceCalculator(
184  $entry,
185  $rec
186  );
187  $dl = $calc->calculateDateList(
188  new ilDateTime('2021-12-31', IL_CAL_DATE),
189  new ilDate('2023-12-31', IL_CAL_DATE),
190  -1
191  );
192  $result = new ilDateList(ilDateList::TYPE_DATE);
193  $result->add(new ilDate('2022-01-01', IL_CAL_DATE));
194  $result->add(new ilDate('2022-01-08', IL_CAL_DATE));
195 
196  $this->assertTrue($result == $dl);
197  }
Calculates an ilDateList for a given calendar entry and recurrence rule.
List of dates.
const IL_CAL_DATE

◆ testWeeklyByDay()

ilCalendarRecurrenceCalculationTest::testWeeklyByDay ( )

Definition at line 199 of file ilCalendarRecurrenceCalculationTest.php.

References ilCalendarRecurrence\FREQ_WEEKLY, IL_CAL_DATE, and ilDateList\TYPE_DATE.

199  : void
200  {
201  $entry = new ilCalendarEntry(0);
202  $entry->setStart(new ilDate('2022-01-01', IL_CAL_DATE));
203  $entry->setEnd(new ilDate('2022-01-01', IL_CAL_DATE));
204  $entry->setFullday(true);
205 
206  $rec = new ilCalendarRecurrence(0);
207  $rec->setFrequenceType(ilCalendarRecurrence::FREQ_WEEKLY);
208  $rec->setBYDAY('MO,SA');
209  $rec->setInterval(1);
210  $rec->setFrequenceUntilCount(3);
211 
212  $calc = new ilCalendarRecurrenceCalculator(
213  $entry,
214  $rec
215  );
216  $dl = $calc->calculateDateList(
217  new ilDateTime('2021-12-31', IL_CAL_DATE),
218  new ilDate('2023-12-31', IL_CAL_DATE),
219  -1
220  );
221  $result = new ilDateList(ilDateList::TYPE_DATE);
222  $result->add(new ilDate('2022-01-01', IL_CAL_DATE));
223  $result->add(new ilDate('2022-01-03', IL_CAL_DATE));
224  $result->add(new ilDate('2022-01-08', IL_CAL_DATE));
225 
226  $this->assertTrue($result == $dl);
227  }
Calculates an ilDateList for a given calendar entry and recurrence rule.
List of dates.
const IL_CAL_DATE

◆ testYearly()

ilCalendarRecurrenceCalculationTest::testYearly ( )

Definition at line 51 of file ilCalendarRecurrenceCalculationTest.php.

References ilCalendarRecurrence\FREQ_YEARLY, and IL_CAL_DATE.

52  {
53  $entry = new ilCalendarEntry(0);
54  $entry->setStart(new ilDate('2022-01-01', IL_CAL_DATE));
55  $entry->setEnd(new ilDate('2022-01-01', IL_CAL_DATE));
56  $entry->setFullday(true);
57 
58  $rec = new ilCalendarRecurrence(0);
59  $rec->setFrequenceType(ilCalendarRecurrence::FREQ_YEARLY);
60  $rec->setInterval(1);
61  $rec->setFrequenceUntilCount(1);
62 
64  $entry,
65  $rec
66  );
67  $dl = $calc->calculateDateList(
68  new ilDateTime('2021-12-31', IL_CAL_DATE),
69  new ilDate('2023-12-31', IL_CAL_DATE),
70  -1
71  );
72  $this->assertCount(1, $dl);
73  foreach ($dl as $date) {
74  $this->assertTrue(strcmp($date->get(IL_CAL_DATE), '2022-01-01') === 0);
75  }
76  }
Calculates an ilDateList for a given calendar entry and recurrence rule.
const IL_CAL_DATE

◆ testYearlyByDay()

ilCalendarRecurrenceCalculationTest::testYearlyByDay ( )

Definition at line 78 of file ilCalendarRecurrenceCalculationTest.php.

References ilCalendarRecurrence\FREQ_YEARLY, IL_CAL_DATE, and ilDateList\TYPE_DATE.

78  : void
79  {
80  $entry = new ilCalendarEntry(0);
81  $entry->setStart(new ilDate('2022-01-01', IL_CAL_DATE));
82  $entry->setEnd(new ilDate('2022-01-01', IL_CAL_DATE));
83  $entry->setFullday(true);
84 
85  // first saturday and second monday in january and december
86  $rec = new ilCalendarRecurrence(0);
87  $rec->setFrequenceType(ilCalendarRecurrence::FREQ_YEARLY);
88  $rec->setBYDAY('1SA,2MO');
89  $rec->setBYMONTH('1,12');
90  $rec->setInterval(1);
91  $rec->setFrequenceUntilCount(6);
92 
94  $entry,
95  $rec
96  );
97  $dl = $calc->calculateDateList(
98  new ilDateTime('2021-12-31', IL_CAL_DATE),
99  new ilDate('2023-12-31', IL_CAL_DATE),
100  -1
101  );
102  $result = new ilDateList(ilDateList::TYPE_DATE);
103  $result->add(new ilDate('2022-01-01', IL_CAL_DATE));
104  $result->add(new ilDate('2022-01-10', IL_CAL_DATE));
105  $result->add(new ilDate('2022-12-03', IL_CAL_DATE));
106  $result->add(new ilDate('2022-12-12', IL_CAL_DATE));
107  $result->add(new ilDate('2023-01-07', IL_CAL_DATE));
108  $result->add(new ilDate('2023-01-09', IL_CAL_DATE));
109 
110  $this->assertTrue($result == $dl);
111  }
Calculates an ilDateList for a given calendar entry and recurrence rule.
List of dates.
const IL_CAL_DATE

Field Documentation

◆ $backupGlobals

ilCalendarRecurrenceCalculationTest::$backupGlobals = false
protected

Definition at line 26 of file ilCalendarRecurrenceCalculationTest.php.

◆ $dic

Container ilCalendarRecurrenceCalculationTest::$dic
protected

Definition at line 27 of file ilCalendarRecurrenceCalculationTest.php.

Referenced by initDependencies().


The documentation for this class was generated from the following file: