ILIAS  release_8 Revision v8.24
ilCalendarRecurrenceCalculationTest Class Reference
+ Inheritance diagram for ilCalendarRecurrenceCalculationTest:
+ Collaboration diagram for ilCalendarRecurrenceCalculationTest:

Public Member Functions

 testCalculatorConstruct ()
 
 testYearly ()
 
 testMonthly ()
 
 testMonthlyByDay ()
 

Protected Member Functions

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

Protected Attributes

 $backupGlobals = false
 
Container $dic
 

Detailed Description

Member Function Documentation

◆ initDependencies()

ilCalendarRecurrenceCalculationTest::initDependencies ( )
protected

Definition at line 145 of file class.ilCalendarRecurrenceCalculationTest.php.

145 : void
146 {
147 $this->dic = new Container();
148 $GLOBALS['DIC'] = $this->dic;
149
150 $this->setGlobalVariable('ilDB', $this->createMock(ilDBInterface::class));
151 $this->setGlobalVariable('lng', $this->createMock(ilLanguage::class));
152 $this->setGlobalVariable('ilErr', $this->createMock(ilErrorHandling::class));
153
154 $logger = $this->getMockBuilder(ilLogger::class)
155 ->disableOriginalConstructor()
156 ->getMock();
157
158 $logger_factory = $this->getMockBuilder(ilLoggerFactory::class)
159 ->disableOriginalConstructor()
160 ->onlyMethods(['getComponentLogger'])
161 ->getMock();
162 $logger_factory->method('getComponentLogger')->willReturn($logger);
163 $this->setGlobalVariable('ilLoggerFactory', $logger_factory);
164 }
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:32

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

Referenced by setUp().

+ 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 134 of file class.ilCalendarRecurrenceCalculationTest.php.

134 : void
135 {
136 global $DIC;
137
138 $GLOBALS[$name] = $value;
139 unset($DIC[$name]);
140 $DIC[$name] = static function (\ILIAS\DI\Container $c) use ($value) {
141 return $value;
142 };
143 }
$c
Definition: cli.php:38
global $DIC
Definition: feed.php:28
if($format !==null) $name
Definition: metadata.php:247

References $c, $DIC, $GLOBALS, and $name.

Referenced by initDependencies().

+ Here is the caller graph for this function:

◆ setUp()

ilCalendarRecurrenceCalculationTest::setUp ( )
protected

Definition at line 27 of file class.ilCalendarRecurrenceCalculationTest.php.

27 : void
28 {
29 $this->initDependencies();
30 parent::setUp();
31 }

References initDependencies().

+ Here is the call graph for this function:

◆ testCalculatorConstruct()

ilCalendarRecurrenceCalculationTest::testCalculatorConstruct ( )

Definition at line 33 of file class.ilCalendarRecurrenceCalculationTest.php.

34 {
35 $entry = new ilCalendarEntry(0);
36 $entry->setStart(new ilDate('2022-01-01', IL_CAL_DATE));
37 $entry->setEnd(new ilDate('2022-01-01', IL_CAL_DATE));
38 $entry->setFullday(true);
39 $entry->setTitle('First');
40 $rec = new ilCalendarRecurrence(0);
41
43 $entry,
44 $rec
45 );
46 $this->assertTrue($calc instanceof ilCalendarRecurrenceCalculator);
47 }
const IL_CAL_DATE
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class for single dates.

References IL_CAL_DATE.

◆ testMonthly()

ilCalendarRecurrenceCalculationTest::testMonthly ( )

Definition at line 76 of file class.ilCalendarRecurrenceCalculationTest.php.

77 {
78 $entry = new ilCalendarEntry(0);
79 $entry->setStart(new ilDate('2022-01-01', IL_CAL_DATE));
80 $entry->setEnd(new ilDate('2023-01-01', IL_CAL_DATE));
81 $entry->setFullday(true);
82
83 $rec = new ilCalendarRecurrence(0);
84 $rec->setFrequenceType(ilCalendarRecurrence::FREQ_MONTHLY);
85 $rec->setInterval(1);
86 $rec->setFrequenceUntilCount(2);
87
89 $entry,
90 $rec
91 );
92 $dl = $calc->calculateDateList(
93 new ilDateTime('2021-12-31', IL_CAL_DATE),
94 new ilDate('2023-12-31', IL_CAL_DATE),
95 -1
96 );
97 $result = new ilDateList(ilDateList::TYPE_DATE);
98 $result->add(new ilDate('2022-01-01', IL_CAL_DATE));
99 $result->add(new ilDate('2022-02-01', IL_CAL_DATE));
100
101 $this->assertTrue($result == $dl);
102 }
List of dates.
@classDescription Date and time handling

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

◆ testMonthlyByDay()

ilCalendarRecurrenceCalculationTest::testMonthlyByDay ( )

Definition at line 104 of file class.ilCalendarRecurrenceCalculationTest.php.

105 {
106 $entry = new ilCalendarEntry(0);
107 $entry->setStart(new ilDate('2022-01-01', IL_CAL_DATE));
108 $entry->setEnd(new ilDate('2023-01-01', IL_CAL_DATE));
109 $entry->setFullday(true);
110
111 // next two first days of the month which are on saturday => (2022-01-01, 2022-10-01)
112 $rec = new ilCalendarRecurrence(0);
113 $rec->setFrequenceType(ilCalendarRecurrence::FREQ_MONTHLY);
114 $rec->setBYDAY('SA');
115 $rec->setBYMONTHDAY('1');
116 $rec->setInterval(1);
117 $rec->setFrequenceUntilCount(2);
118
120 $entry,
121 $rec
122 );
123 $dl = $calc->calculateDateList(
124 new ilDateTime('2021-12-31', IL_CAL_DATE),
125 new ilDate('2023-12-31', IL_CAL_DATE),
126 -1
127 );
128 $result = new ilDateList(ilDateList::TYPE_DATE);
129 $result->add(new ilDate('2022-01-01', IL_CAL_DATE));
130 $result->add(new ilDate('2022-10-01', IL_CAL_DATE));
131 $this->assertTrue($result == $dl);
132 }

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

◆ testYearly()

ilCalendarRecurrenceCalculationTest::testYearly ( )

Definition at line 49 of file class.ilCalendarRecurrenceCalculationTest.php.

50 {
51 $entry = new ilCalendarEntry(0);
52 $entry->setStart(new ilDate('2022-01-01', IL_CAL_DATE));
53 $entry->setEnd(new ilDate('2022-01-01', IL_CAL_DATE));
54 $entry->setFullday(true);
55
56 $rec = new ilCalendarRecurrence(0);
57 $rec->setFrequenceType(ilCalendarRecurrence::FREQ_YEARLY);
58 $rec->setInterval(1);
59 $rec->setFrequenceUntilCount(1);
60
62 $entry,
63 $rec
64 );
65 $dl = $calc->calculateDateList(
66 new ilDateTime('2021-12-31', IL_CAL_DATE),
67 new ilDate('2023-12-31', IL_CAL_DATE),
68 -1
69 );
70 $this->assertCount(1, $dl);
71 foreach ($dl as $date) {
72 $this->assertTrue(strcmp($date->get(IL_CAL_DATE), '2022-01-01') === 0);
73 }
74 }

References ilCalendarRecurrence\FREQ_YEARLY, and IL_CAL_DATE.

Field Documentation

◆ $backupGlobals

ilCalendarRecurrenceCalculationTest::$backupGlobals = false
protected

◆ $dic

Container ilCalendarRecurrenceCalculationTest::$dic
protected

Definition at line 25 of file class.ilCalendarRecurrenceCalculationTest.php.

Referenced by initDependencies().


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