40 $this->timezoneBackup = date_default_timezone_get();
41 date_default_timezone_set(
'UTC');
45 date_default_timezone_set($this->timezoneBackup);
53 $instance = new \TYPO3\CMS\Scheduler\CronCommand\CronCommand(
'2-3 * * * *');
54 $this->assertSame(array(
'2,3',
'*',
'*',
'*',
'*'), $instance->getCronCommandSections());
62 new \TYPO3\CMS\Scheduler\CronCommand\CronCommand(
'61 * * * *');
69 $instance = new \TYPO3\CMS\Scheduler\CronCommand\CronCommand(
'* * * * *');
70 $currentTime = time();
71 $expectedTime = $currentTime - ($currentTime % 60) + 60;
72 $this->assertSame($expectedTime, $instance->getTimestamp());
79 $instance = new \TYPO3\CMS\Scheduler\CronCommand\CronCommand(
'* * * * *', self::TIMESTAMP);
80 $this->assertSame(self::TIMESTAMP + 60, $instance->getTimestamp());
87 $instance = new \TYPO3\CMS\Scheduler\CronCommand\CronCommand(
'* * * * *', self::TIMESTAMP + 1);
88 $this->assertSame(self::TIMESTAMP + 60, $instance->getTimestamp());
96 'every minute' => array(
100 self::TIMESTAMP + 120
102 'once an hour at 1' => array(
105 self::TIMESTAMP + 60,
106 self::TIMESTAMP + 60 + 60 * 60
108 'once an hour at 0' => array(
111 self::TIMESTAMP + 60 * 60,
112 self::TIMESTAMP + 60 * 60 + 60 * 60
114 'once a day at 1:00' => array(
117 self::TIMESTAMP + 60 * 60,
118 self::TIMESTAMP + 60 * 60 + 60 * 60 * 24
120 'once a day at 0:00' => array(
123 self::TIMESTAMP + 60 * 60 * 24,
124 self::TIMESTAMP + 60 * 60 * 24 * 2
126 'once a month' => array(
129 self::TIMESTAMP + 60 * 60 * 24 * 3,
130 self::TIMESTAMP + 60 * 60 * 24 * 3 + 60 * 60 * 24 * 31
132 'once every Saturday' => array(
135 self::TIMESTAMP + 60 * 60 * 24,
136 self::TIMESTAMP + 60 * 60 * 24 + 60 * 60 * 24 * 7
138 'once every day in February' => array(
141 self::TIMESTAMP + 60 * 60 * 24 * 31,
142 self::TIMESTAMP + 60 * 60 * 24 * 31 + 60 * 60 * 24
144 'day of week and day of month restricted, next match in day of month field' => array(
147 self::TIMESTAMP + 60 * 60 * 24,
148 self::TIMESTAMP + 60 * 60 * 24 + 60 * 60 * 24
150 'day of week and day of month restricted, next match in day of week field' => array(
153 self::TIMESTAMP + 60 * 60 * 24,
154 self::TIMESTAMP + 60 * 60 * 24 + 60 * 60 * 24
156 'list of minutes' => array(
159 self::TIMESTAMP + 120,
160 self::TIMESTAMP + 240
162 'list of hours' => array(
165 self::TIMESTAMP + 60 * 60 * 2,
166 self::TIMESTAMP + 60 * 60 * 4
176 'every first day of month' => array(
182 'once every February' => array(
188 'once every Friday February' => array(
194 'first day in February and every Friday' => array(
200 '29th February leap year' => array(
206 'list of days in month' => array(
212 'list of month' => array(
218 'list of days of weeks' => array(
235 $instance = new \TYPO3\CMS\Scheduler\CronCommand\CronCommand($cronCommand, $startTimestamp);
236 $instance->calculateNextValue();
237 $this->assertSame($expectedTimestamp, $instance->getTimestamp());
248 $instance = new \TYPO3\CMS\Scheduler\CronCommand\CronCommand($cronCommand, $startTimestamp);
249 $instance->calculateNextValue();
250 $this->assertSame(strtotime($expectedTimestamp), $instance->getTimestamp());
262 $instance = new \TYPO3\CMS\Scheduler\CronCommand\CronCommand($cronCommand, $firstTimestamp);
263 $instance->calculateNextValue();
264 $this->assertSame($secondTimestamp, $instance->getTimestamp());
276 $instance = new \TYPO3\CMS\Scheduler\CronCommand\CronCommand($cronCommand, strtotime($firstTimestamp));
277 $instance->calculateNextValue();
278 $this->assertSame(strtotime($secondTimestamp), $instance->getTimestamp());
285 $backupTimezone = date_default_timezone_get();
286 date_default_timezone_set(
'Europe/Berlin');
287 $instance = new \TYPO3\CMS\Scheduler\CronCommand\CronCommand(
'* 3 28 mar *', self::TIMESTAMP);
288 $instance->calculateNextValue();
289 date_default_timezone_set($backupTimezone);
290 $this->assertSame(1269741600, $instance->getTimestamp());
298 $instance = new \TYPO3\CMS\Scheduler\CronCommand\CronCommand(
'* * 31 apr *', self::TIMESTAMP);
299 $instance->calculateNextValue();
306 $instance = new \TYPO3\CMS\Scheduler\CronCommand\CronCommand(
'* * * * *');
307 $this->assertInternalType(\PHPUnit_Framework_Constraint_IsType::TYPE_INT, $instance->getTimestamp());
314 $instance = new \TYPO3\CMS\Scheduler\CronCommand\CronCommand(
'* * * * *');
315 $this->assertInternalType(\PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $instance->getCronCommandSections());
calculateNextValueDeterminesCorrectNextCalculatedTimestampOnConsecutiveCall($cronCommand, $startTimestamp, $firstTimestamp, $secondTimestamp)
constructorThrowsExceptionForInvalidCronCommand()
calculateNextValueThrowsExceptionWithImpossibleCronCommand()
calculateNextValueDeterminesCorrectNextTimestamp($cronCommand, $startTimestamp, $expectedTimestamp)
calculateNextValueDeterminesCorrectNextTimestampOnChangeToSummertime()
calculateNextValueDeterminesCorrectNextTimestampOnConsecutiveCall($cronCommand, $startTimestamp, $firstTimestamp, $secondTimestamp)
static expectedTimestampDataProvider()
constructorSetsTimestampToNowPlusOneMinuteRoundedDownToSixtySeconds()
constructorSetsTimestampToGivenTimestampPlusSixtySeconds()
constructorSetsNormalizedCronCommandSections()
constructorSetsTimestampToGiveTimestampRoundedDownToSixtySeconds()
getCronCommandSectionsReturnsArray()
calculateNextValueDeterminesCorrectNextCalculatedTimestamp($cronCommand, $startTimestamp, $expectedTimestamp)
static expectedCalculatedTimestampDataProvider()
getTimestampReturnsInteger()