|
4 | 4 |
|
5 | 5 | use Firebase\JWT\ExpiredException;
|
6 | 6 | use Google\Cloud\Tasks\V2\RetryConfig;
|
| 7 | +use Google\Cloud\Tasks\V2\Task; |
7 | 8 | use Google\Protobuf\Duration;
|
8 | 9 | use Illuminate\Queue\Events\JobProcessed;
|
9 | 10 | use Illuminate\Queue\Events\JobProcessing;
|
| 11 | +use Illuminate\Support\Carbon; |
10 | 12 | use Illuminate\Support\Facades\Event;
|
11 | 13 | use Illuminate\Support\Facades\Log;
|
12 | 14 | use Stackkit\LaravelGoogleCloudTasksQueue\CloudTasksApi;
|
@@ -475,4 +477,33 @@ public function attempts_are_copied_from_x_header()
|
475 | 477 | return $event->job->attempts() === 7;
|
476 | 478 | });
|
477 | 479 | }
|
| 480 | + |
| 481 | + /** |
| 482 | + * @test |
| 483 | + */ |
| 484 | + public function retried_jobs_get_a_new_name() |
| 485 | + { |
| 486 | + // Arrange |
| 487 | + OpenIdVerificator::fake(); |
| 488 | + Event::fake($this->getJobReleasedAfterExceptionEvent()); |
| 489 | + CloudTasksApi::fake(); |
| 490 | + |
| 491 | + // Act & Assert |
| 492 | + Carbon::setTestNow(Carbon::createFromTimestamp(1685035628)); |
| 493 | + $job = $this->dispatch(new FailingJob()); |
| 494 | + Carbon::setTestNow(Carbon::createFromTimestamp(1685035629)); |
| 495 | + |
| 496 | + $job->run(); |
| 497 | + |
| 498 | + // Assert |
| 499 | + CloudTasksApi::assertCreatedTaskCount(2); |
| 500 | + CloudTasksApi::assertTaskCreated(function (Task $task): bool { |
| 501 | + [$timestamp] = array_reverse(explode('-', $task->getName())); |
| 502 | + return $timestamp === '1685035628'; |
| 503 | + }); |
| 504 | + CloudTasksApi::assertTaskCreated(function (Task $task): bool { |
| 505 | + [$timestamp] = array_reverse(explode('-', $task->getName())); |
| 506 | + return $timestamp === '1685035629'; |
| 507 | + }); |
| 508 | + } |
478 | 509 | }
|
0 commit comments