|
16 | 16 | use Illuminate\Support\Facades\Queue;
|
17 | 17 | use PHPUnit\Framework\Attributes\Test;
|
18 | 18 | use Stackkit\LaravelGoogleCloudTasksQueue\CloudTasksApi;
|
| 19 | +use Stackkit\LaravelGoogleCloudTasksQueue\CloudTasksQueue; |
19 | 20 | use Stackkit\LaravelGoogleCloudTasksQueue\Events\JobReleased;
|
20 | | -use Tests\Support\CustomHandlerUrlJob; |
21 | | -use Tests\Support\CustomHeadersJob; |
22 | 21 | use Tests\Support\FailingJob;
|
23 | 22 | use Tests\Support\FailingJobWithExponentialBackoff;
|
24 | 23 | use Tests\Support\JobOutput;
|
@@ -76,18 +75,21 @@ public function it_posts_to_the_configured_handler_url()
|
76 | 75 | }
|
77 | 76 |
|
78 | 77 | #[Test]
|
79 | | - public function it_posts_to_the_job_handler_url() |
| 78 | + public function it_posts_to_the_callback_handler_url() |
80 | 79 | {
|
81 | 80 | // Arrange
|
82 | 81 | $this->setConfigValue('handler', 'https://docker.for.mac.localhost:8081');
|
83 | 82 | CloudTasksApi::fake();
|
| 83 | + CloudTasksQueue::configureHandlerUrlUsing(static fn(SimpleJob $job) => 'https://example.com/api/my-custom-route?job=' . $job->id); |
84 | 84 |
|
85 | 85 | // Act
|
86 | | - $this->dispatch(new CustomHandlerUrlJob()); |
| 86 | + $job = new SimpleJob(); |
| 87 | + $job->id = 1; |
| 88 | + $this->dispatch($job); |
87 | 89 |
|
88 | 90 | // Assert
|
89 | 91 | CloudTasksApi::assertTaskCreated(function (Task $task): bool {
|
90 | | - return $task->getHttpRequest()->getUrl() === 'https://example.com/api/my-custom-route'; |
| 92 | + return $task->getHttpRequest()->getUrl() === 'https://example.com/api/my-custom-route?job=1'; |
91 | 93 | });
|
92 | 94 | }
|
93 | 95 |
|
@@ -510,23 +512,4 @@ public function headers_can_be_added_to_the_task_with_job_context()
|
510 | 512 | return $task->getHttpRequest()->getHeaders()['X-MyHeader'] === SimpleJob::class;
|
511 | 513 | });
|
512 | 514 | }
|
513 | | - |
514 | | - #[Test] |
515 | | - public function job_headers_can_be_added_to_the_task() |
516 | | - { |
517 | | - // Arrange |
518 | | - CloudTasksApi::fake(); |
519 | | - |
520 | | - // Act |
521 | | - Queue::connection()->setTaskHeaders([ |
522 | | - 'X-MyHeader' => 'MyValue', |
523 | | - ]); |
524 | | - $this->dispatch((new CustomHeadersJob())); |
525 | | - |
526 | | - // Assert |
527 | | - CloudTasksApi::assertTaskCreated(function (Task $task): bool { |
528 | | - $headers = $task->getHttpRequest()->getHeaders(); |
529 | | - return $headers['X-MyHeader'] === 'MyValue' && $headers['X-MyJobHeader'] === 'MyJobValue'; |
530 | | - }); |
531 | | - } |
532 | 515 | }
|
0 commit comments