Skip to content

Commit 641328b

Browse files
committed
tests: make sure the job is added to the queue with the proper delay
1 parent 269f5fe commit 641328b

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

phpunit.xml.dist

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
stopOnFailure="false"
1313
stopOnIncomplete="false"
1414
stopOnSkipped="false"
15-
cacheDirectory=".phpunit.cache"
15+
cacheDirectory="build/.phpunit.cache"
1616
beStrictAboutCoverageMetadata="true">
1717

1818
<coverage includeUncoveredFiles="true">

tests/DatabaseHandlerTest.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public function testPushAndPopWithPriority(): void
152152
}
153153

154154
/**
155-
* @throws ReflectionException
155+
* @throws Exception
156156
*/
157157
public function testPushWithDelay(): void
158158
{
@@ -162,11 +162,16 @@ public function testPushWithDelay(): void
162162
$result = $handler->setDelay(MINUTE)->push('queue-delay', 'success', ['key' => 'value']);
163163

164164
$this->assertTrue($result);
165+
166+
$availableAt = 1703859376;
167+
165168
$this->seeInDatabase('queue_jobs', [
166169
'queue' => 'queue-delay',
167170
'payload' => json_encode(['job' => 'success', 'data' => ['key' => 'value']]),
168-
'available_at' => 1703859376,
171+
'available_at' => $availableAt,
169172
]);
173+
174+
$this->assertEqualsWithDelta(MINUTE, $availableAt - Time::now()->getTimestamp(), 1);
170175
}
171176

172177
public function testPushWithDelayException(): void

0 commit comments

Comments
 (0)