e
This commit is contained in:
@@ -70,6 +70,25 @@ class CronExpressionTest
|
||||
$next = $this->parser->getNextRunTime('every:60', $now);
|
||||
$this->assertTrue($next === $now + 60, "期望 " . ($now + 60) . " 实际 $next");
|
||||
}
|
||||
/**
|
||||
* 测试毫秒级 every:100ms 表达式
|
||||
*/
|
||||
public function testEveryMilliseconds(): void
|
||||
{
|
||||
$nowMs = 1760000000123;
|
||||
$next = $this->parser->getNextRunTimeMs('every:100ms', $nowMs);
|
||||
$this->assertTrue($next === $nowMs + 100, "期望 " . ($nowMs + 100) . " 实际 $next");
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试秒级表达式在毫秒级接口中返回毫秒时间戳
|
||||
*/
|
||||
public function testEverySecondsAsMilliseconds(): void
|
||||
{
|
||||
$nowMs = 1760000000123;
|
||||
$next = $this->parser->getNextRunTimeMs('every:1s', $nowMs);
|
||||
$this->assertTrue($next === $nowMs + 1000, "期望 " . ($nowMs + 1000) . " 实际 $next");
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试 every:5m 表达式
|
||||
@@ -159,6 +178,13 @@ class CronExpressionTest
|
||||
$expected = mktime(10, 5, 0, 1, 15, 2026);
|
||||
$this->assertTrue($next === $expected, "期望 $expected 实际 $next");
|
||||
}
|
||||
public function testCronAlignsToMinuteBoundary(): void
|
||||
{
|
||||
$now = mktime(10, 2, 30, 1, 15, 2026); // 10:02:30
|
||||
$next = $this->parser->getNextRunTime('cron:*/5 * * * *', $now);
|
||||
$expected = mktime(10, 5, 0, 1, 15, 2026);
|
||||
$this->assertTrue($next === $expected, "期望 $expected 实际 $next");
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试 cron 表达式精确时间
|
||||
|
||||
Reference in New Issue
Block a user