Skip to content

Commit

Permalink
tests: make sure the job is added to the queue with the proper delay
Browse files Browse the repository at this point in the history
  • Loading branch information
michalsn committed Jan 31, 2025
1 parent 269f5fe commit 641328b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
cacheDirectory=".phpunit.cache"
cacheDirectory="build/.phpunit.cache"
beStrictAboutCoverageMetadata="true">

<coverage includeUncoveredFiles="true">
Expand Down
9 changes: 7 additions & 2 deletions tests/DatabaseHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public function testPushAndPopWithPriority(): void
}

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

$this->assertTrue($result);

$availableAt = 1703859376;

$this->seeInDatabase('queue_jobs', [
'queue' => 'queue-delay',
'payload' => json_encode(['job' => 'success', 'data' => ['key' => 'value']]),
'available_at' => 1703859376,
'available_at' => $availableAt,
]);

$this->assertEqualsWithDelta(MINUTE, $availableAt - Time::now()->getTimestamp(), 1);
}

public function testPushWithDelayException(): void
Expand Down

0 comments on commit 641328b

Please sign in to comment.