Skip to content

Commit bc19508

Browse files
authored
[12.x] Adjust testCanRetrieveAllFailedJobs (#58096)
* Update FileFailedJobProviderTest.php * Update FileFailedJobProviderTest.php
1 parent d3d7c2e commit bc19508

File tree

1 file changed

+32
-25
lines changed

1 file changed

+32
-25
lines changed

tests/Queue/FileFailedJobProviderTest.php

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Exception;
66
use Illuminate\Queue\Failed\FileFailedJobProvider;
7+
use Illuminate\Support\Carbon;
78
use Illuminate\Support\Str;
89
use PHPUnit\Framework\TestCase;
910

@@ -40,31 +41,37 @@ public function testCanLogFailedJobs()
4041

4142
public function testCanRetrieveAllFailedJobs()
4243
{
43-
[$uuidOne, $exceptionOne] = $this->logFailedJob();
44-
[$uuidTwo, $exceptionTwo] = $this->logFailedJob();
45-
46-
$failedJobs = $this->provider->all();
47-
48-
$this->assertEquals([
49-
(object) [
50-
'id' => $uuidTwo,
51-
'connection' => 'connection',
52-
'queue' => 'queue',
53-
'payload' => json_encode(['uuid' => $uuidTwo]),
54-
'exception' => (string) mb_convert_encoding($exceptionTwo, 'UTF-8'),
55-
'failed_at' => $failedJobs[1]->failed_at,
56-
'failed_at_timestamp' => $failedJobs[1]->failed_at_timestamp,
57-
],
58-
(object) [
59-
'id' => $uuidOne,
60-
'connection' => 'connection',
61-
'queue' => 'queue',
62-
'payload' => json_encode(['uuid' => $uuidOne]),
63-
'exception' => (string) mb_convert_encoding($exceptionOne, 'UTF-8'),
64-
'failed_at' => $failedJobs[0]->failed_at,
65-
'failed_at_timestamp' => $failedJobs[0]->failed_at_timestamp,
66-
],
67-
], $failedJobs);
44+
try {
45+
Carbon::setTestNow(now());
46+
47+
[$uuidOne, $exceptionOne] = $this->logFailedJob();
48+
[$uuidTwo, $exceptionTwo] = $this->logFailedJob();
49+
50+
$failedJobs = $this->provider->all();
51+
52+
$this->assertEquals([
53+
(object) [
54+
'id' => $uuidTwo,
55+
'connection' => 'connection',
56+
'queue' => 'queue',
57+
'payload' => json_encode(['uuid' => $uuidTwo]),
58+
'exception' => (string) mb_convert_encoding($exceptionTwo, 'UTF-8'),
59+
'failed_at' => $failedJobs[1]->failed_at,
60+
'failed_at_timestamp' => $failedJobs[1]->failed_at_timestamp,
61+
],
62+
(object) [
63+
'id' => $uuidOne,
64+
'connection' => 'connection',
65+
'queue' => 'queue',
66+
'payload' => json_encode(['uuid' => $uuidOne]),
67+
'exception' => (string) mb_convert_encoding($exceptionOne, 'UTF-8'),
68+
'failed_at' => $failedJobs[0]->failed_at,
69+
'failed_at_timestamp' => $failedJobs[0]->failed_at_timestamp,
70+
],
71+
], $failedJobs);
72+
} finally {
73+
Carbon::setTestNow();
74+
}
6875
}
6976

7077
public function testCanFindFailedJobs()

0 commit comments

Comments
 (0)