|
4 | 4 |
|
5 | 5 | use Exception; |
6 | 6 | use Illuminate\Queue\Failed\FileFailedJobProvider; |
| 7 | +use Illuminate\Support\Carbon; |
7 | 8 | use Illuminate\Support\Str; |
8 | 9 | use PHPUnit\Framework\TestCase; |
9 | 10 |
|
@@ -40,31 +41,37 @@ public function testCanLogFailedJobs() |
40 | 41 |
|
41 | 42 | public function testCanRetrieveAllFailedJobs() |
42 | 43 | { |
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 | + } |
68 | 75 | } |
69 | 76 |
|
70 | 77 | public function testCanFindFailedJobs() |
|
0 commit comments