2 namespace TYPO3\CMS\Scheduler\Tests\Unit\CronCommand;
42 $this->timezoneBackup = date_default_timezone_get();
43 date_default_timezone_set(
'UTC');
48 date_default_timezone_set($this->timezoneBackup);
58 $this->assertSame(array(
'2,3',
'*',
'*',
'*',
'*'), $instance->getCronCommandSections());
76 $currentTime = time();
77 $expectedTime = $currentTime - ($currentTime % 60) + 60;
78 $this->assertSame($expectedTime, $instance->getTimestamp());
86 $instance =
new CronCommand(
'* * * * *', self::TIMESTAMP);
87 $this->assertSame(self::TIMESTAMP + 60, $instance->getTimestamp());
95 $instance =
new CronCommand(
'* * * * *', self::TIMESTAMP + 1);
96 $this->assertSame(self::TIMESTAMP + 60, $instance->getTimestamp());
105 'every minute' => array(
108 self::TIMESTAMP + 60,
109 self::TIMESTAMP + 120
111 'once an hour at 1' => array(
114 self::TIMESTAMP + 60,
115 self::TIMESTAMP + 60 + 60 * 60
117 'once an hour at 0' => array(
120 self::TIMESTAMP + 60 * 60,
121 self::TIMESTAMP + 60 * 60 + 60 * 60
123 'once a day at 1:00' => array(
126 self::TIMESTAMP + 60 * 60,
127 self::TIMESTAMP + 60 * 60 + 60 * 60 * 24
129 'once a day at 0:00' => array(
132 self::TIMESTAMP + 60 * 60 * 24,
133 self::TIMESTAMP + 60 * 60 * 24 * 2
135 'once a month' => array(
138 self::TIMESTAMP + 60 * 60 * 24 * 3,
139 self::TIMESTAMP + 60 * 60 * 24 * 3 + 60 * 60 * 24 * 31
141 'once every Saturday' => array(
144 self::TIMESTAMP + 60 * 60 * 24,
145 self::TIMESTAMP + 60 * 60 * 24 + 60 * 60 * 24 * 7
147 'once every day in February' => array(
150 self::TIMESTAMP + 60 * 60 * 24 * 31,
151 self::TIMESTAMP + 60 * 60 * 24 * 31 + 60 * 60 * 24
153 'day of week and day of month restricted, next match in day of month field' => array(
156 self::TIMESTAMP + 60 * 60 * 24,
157 self::TIMESTAMP + 60 * 60 * 24 + 60 * 60 * 24
159 'day of week and day of month restricted, next match in day of week field' => array(
162 self::TIMESTAMP + 60 * 60 * 24,
163 self::TIMESTAMP + 60 * 60 * 24 + 60 * 60 * 24
165 'list of minutes' => array(
168 self::TIMESTAMP + 120,
169 self::TIMESTAMP + 240
171 'list of hours' => array(
174 self::TIMESTAMP + 60 * 60 * 2,
175 self::TIMESTAMP + 60 * 60 * 4
186 'every first day of month' => array(
192 'once every February' => array(
198 'once every Friday February' => array(
204 'first day in February and every Friday' => array(
210 '29th February leap year' => array(
216 'list of days in month' => array(
222 'list of month' => array(
228 'list of days of weeks' => array(
246 $instance =
new CronCommand($cronCommand, $startTimestamp);
247 $instance->calculateNextValue();
248 $this->assertSame($expectedTimestamp, $instance->getTimestamp());
260 $instance =
new CronCommand($cronCommand, $startTimestamp);
261 $instance->calculateNextValue();
262 $this->assertSame(strtotime($expectedTimestamp), $instance->getTimestamp());
275 $instance =
new CronCommand($cronCommand, $firstTimestamp);
276 $instance->calculateNextValue();
277 $this->assertSame($secondTimestamp, $instance->getTimestamp());
290 $instance =
new CronCommand($cronCommand, strtotime($firstTimestamp));
291 $instance->calculateNextValue();
292 $this->assertSame(strtotime($secondTimestamp), $instance->getTimestamp());
300 $backupTimezone = date_default_timezone_get();
301 date_default_timezone_set(
'Europe/Berlin');
302 $instance =
new CronCommand(
'* 3 28 mar *', self::TIMESTAMP);
303 $instance->calculateNextValue();
304 date_default_timezone_set($backupTimezone);
305 $this->assertSame(1269741600, $instance->getTimestamp());
314 $instance =
new CronCommand(
'* * 31 apr *', self::TIMESTAMP);
315 $instance->calculateNextValue();
324 $this->assertInternalType(\PHPUnit_Framework_Constraint_IsType::TYPE_INT, $instance->getTimestamp());
333 $this->assertInternalType(\PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $instance->getCronCommandSections());