ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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

Definition at line 24 of file ilCalendarRecurrenceCalculationTest.php.

Member Function Documentation

◆ initDependencies()

ilCalendarRecurrenceCalculationTest::initDependencies ( )
protected

Definition at line 147 of file ilCalendarRecurrenceCalculationTest.php.

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

Referenced by setUp().

147  : void
148  {
149  $this->dic = new Container();
150  $GLOBALS['DIC'] = $this->dic;
151 
152  $this->setGlobalVariable('ilDB', $this->createMock(ilDBInterface::class));
153  $this->setGlobalVariable('lng', $this->createMock(ilLanguage::class));
154  $this->setGlobalVariable('ilErr', $this->createMock(ilErrorHandling::class));
155 
156  $logger = $this->getMockBuilder(ilLogger::class)
157  ->disableOriginalConstructor()
158  ->getMock();
159 
160  $logger_factory = $this->getMockBuilder(ilLoggerFactory::class)
161  ->disableOriginalConstructor()
162  ->onlyMethods(['getComponentLogger'])
163  ->getMock();
164  $logger_factory->method('getComponentLogger')->willReturn($logger);
165  $this->setGlobalVariable('ilLoggerFactory', $logger_factory);
166  }
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:35
$GLOBALS["DIC"]
Definition: wac.php:53
+ 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 136 of file ilCalendarRecurrenceCalculationTest.php.

References $c, $DIC, and $GLOBALS.

Referenced by initDependencies().

136  : void
137  {
138  global $DIC;
139 
140  $GLOBALS[$name] = $value;
141  unset($DIC[$name]);
142  $DIC[$name] = static function (\ILIAS\DI\Container $c) use ($value) {
143  return $value;
144  };
145  }
$c
Definition: deliver.php:25
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:35
$GLOBALS["DIC"]
Definition: wac.php:53
global $DIC
Definition: shib_login.php:22
+ 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.

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  }
Model of calendar entry recurrcences based on iCalendar-RFC-5545.
Calculates an ilDateList for a given calendar entry and recurrence rule.
const IL_CAL_DATE

◆ testMonthly()

ilCalendarRecurrenceCalculationTest::testMonthly ( )

Definition at line 78 of file ilCalendarRecurrenceCalculationTest.php.

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

79  {
80  $entry = new ilCalendarEntry(0);
81  $entry->setStart(new ilDate('2022-01-01', IL_CAL_DATE));
82  $entry->setEnd(new ilDate('2023-01-01', IL_CAL_DATE));
83  $entry->setFullday(true);
84 
85  $rec = new ilCalendarRecurrence(0);
86  $rec->setFrequenceType(ilCalendarRecurrence::FREQ_MONTHLY);
87  $rec->setInterval(1);
88  $rec->setFrequenceUntilCount(2);
89 
91  $entry,
92  $rec
93  );
94  $dl = $calc->calculateDateList(
95  new ilDateTime('2021-12-31', IL_CAL_DATE),
96  new ilDate('2023-12-31', IL_CAL_DATE),
97  -1
98  );
99  $result = new ilDateList(ilDateList::TYPE_DATE);
100  $result->add(new ilDate('2022-01-01', IL_CAL_DATE));
101  $result->add(new ilDate('2022-02-01', IL_CAL_DATE));
102 
103  $this->assertTrue($result == $dl);
104  }
Model of calendar entry recurrcences based on iCalendar-RFC-5545.
Calculates an ilDateList for a given calendar entry and recurrence rule.
List of dates.
const IL_CAL_DATE

◆ testMonthlyByDay()

ilCalendarRecurrenceCalculationTest::testMonthlyByDay ( )

Definition at line 106 of file ilCalendarRecurrenceCalculationTest.php.

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

107  {
108  $entry = new ilCalendarEntry(0);
109  $entry->setStart(new ilDate('2022-01-01', IL_CAL_DATE));
110  $entry->setEnd(new ilDate('2023-01-01', IL_CAL_DATE));
111  $entry->setFullday(true);
112 
113  // next two first days of the month which are on saturday => (2022-01-01, 2022-10-01)
114  $rec = new ilCalendarRecurrence(0);
115  $rec->setFrequenceType(ilCalendarRecurrence::FREQ_MONTHLY);
116  $rec->setBYDAY('SA');
117  $rec->setBYMONTHDAY('1');
118  $rec->setInterval(1);
119  $rec->setFrequenceUntilCount(2);
120 
121  $calc = new ilCalendarRecurrenceCalculator(
122  $entry,
123  $rec
124  );
125  $dl = $calc->calculateDateList(
126  new ilDateTime('2021-12-31', IL_CAL_DATE),
127  new ilDate('2023-12-31', IL_CAL_DATE),
128  -1
129  );
130  $result = new ilDateList(ilDateList::TYPE_DATE);
131  $result->add(new ilDate('2022-01-01', IL_CAL_DATE));
132  $result->add(new ilDate('2022-10-01', IL_CAL_DATE));
133  $this->assertTrue($result == $dl);
134  }
Model of calendar entry recurrcences based on iCalendar-RFC-5545.
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  }
Model of calendar entry recurrcences based on iCalendar-RFC-5545.
Calculates an ilDateList for a given calendar entry and recurrence rule.
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: