Skip to content

Commit 981c997

Browse files
author
Marick van Tuil
committed
Pint
1 parent 49fceca commit 981c997

11 files changed

+54
-54
lines changed

src/CloudTasksApi.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ protected static function getFacadeAccessor(): string
2222

2323
public static function fake(): void
2424
{
25-
self::swap(new CloudTasksApiFake());
25+
self::swap(new CloudTasksApiFake);
2626
}
2727
}

src/CloudTasksApiFake.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function deleteTask(string $taskName): void
2828

2929
public function getTask(string $taskName): Task
3030
{
31-
return (new Task())
31+
return (new Task)
3232
->setName($taskName);
3333
}
3434

src/CloudTasksJob.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function __construct(
4141

4242
public function getJobId(): string
4343
{
44-
return $this->uuid() ?? throw new Exception();
44+
return $this->uuid() ?? throw new Exception;
4545
}
4646

4747
/**

src/CloudTasksQueue.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ protected function pushToCloudTasks($queue, $payload, $delay, mixed $job)
165165

166166
$payload = (array) json_decode($payload, true);
167167

168-
$task = tap(new Task())->setName($this->taskName($queue, $payload['displayName']));
168+
$task = tap(new Task)->setName($this->taskName($queue, $payload['displayName']));
169169

170170
$payload = $this->enrichPayloadWithAttempts($payload);
171171

@@ -217,21 +217,21 @@ public function addPayloadToTask(array $payload, Task $task, mixed $job): Task
217217
if (! empty($this->config['app_engine'])) {
218218
$path = \Safe\parse_url(route('cloud-tasks.handle-task'), PHP_URL_PATH);
219219

220-
$appEngineRequest = new AppEngineHttpRequest();
220+
$appEngineRequest = new AppEngineHttpRequest;
221221
$appEngineRequest->setRelativeUri($path);
222222
$appEngineRequest->setHttpMethod(HttpMethod::POST);
223223
$appEngineRequest->setBody(json_encode($payload));
224224
$appEngineRequest->setHeaders($headers);
225225

226226
if (! empty($service = $this->config['app_engine_service'])) {
227-
$routing = new AppEngineRouting();
227+
$routing = new AppEngineRouting;
228228
$routing->setService($service);
229229
$appEngineRequest->setAppEngineRouting($routing);
230230
}
231231

232232
$task->setAppEngineHttpRequest($appEngineRequest);
233233
} else {
234-
$httpRequest = new HttpRequest();
234+
$httpRequest = new HttpRequest;
235235
$httpRequest->setUrl($this->getHandler($job));
236236
$httpRequest->setBody(json_encode($payload));
237237
$httpRequest->setHttpMethod(HttpMethod::POST);

src/TaskHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ private function run(IncomingTask $task): void
6767

6868
public function getWorkerOptions(): WorkerOptions
6969
{
70-
$options = new WorkerOptions();
70+
$options = new WorkerOptions;
7171

7272
if (isset($this->config['backoff'])) {
7373
$options->backoff = $this->config['backoff'];

tests/CloudTasksApiTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ protected function setUp(): void
3838
$this->setConfigValue('location', env('CI_CLOUD_TASKS_LOCATION'));
3939
$this->setConfigValue('service_account_email', env('CI_CLOUD_TASKS_SERVICE_ACCOUNT_EMAIL'));
4040

41-
$this->client = new CloudTasksClient();
41+
$this->client = new CloudTasksClient;
4242

4343
}
4444

@@ -64,11 +64,11 @@ public function custom_client_options_can_be_added()
6464
public function test_create_task()
6565
{
6666
// Arrange
67-
$httpRequest = new HttpRequest();
67+
$httpRequest = new HttpRequest;
6868
$httpRequest->setHttpMethod(HttpMethod::GET);
6969
$httpRequest->setUrl('https://example.com');
7070

71-
$cloudTask = new Task();
71+
$cloudTask = new Task;
7272
$cloudTask->setHttpRequest($httpRequest);
7373

7474
// Act
@@ -112,11 +112,11 @@ public function test_delete_task_on_non_existing_task()
112112
public function test_delete_task()
113113
{
114114
// Arrange
115-
$httpRequest = new HttpRequest();
115+
$httpRequest = new HttpRequest;
116116
$httpRequest->setHttpMethod(HttpMethod::GET);
117117
$httpRequest->setUrl('https://example.com');
118118

119-
$cloudTask = new Task();
119+
$cloudTask = new Task;
120120
$cloudTask->setHttpRequest($httpRequest);
121121
$cloudTask->setScheduleTime(new Timestamp(['seconds' => time() + 10]));
122122

tests/ConfigHandlerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function test_it_allows_a_handler_url_to_contain_path(string $handler, st
2020

2121
$this->setConfigValue('handler', $handler);
2222

23-
$this->dispatch(new SimpleJob());
23+
$this->dispatch(new SimpleJob);
2424

2525
CloudTasksApi::assertTaskCreated(function (Task $task) use ($expectedHandler) {
2626
return $task->getHttpRequest()->getUrl() === $expectedHandler;
@@ -34,7 +34,7 @@ public function the_handle_route_task_uri_can_be_configured(): void
3434

3535
$this->app['config']->set('cloud-tasks.uri', 'my-custom-route');
3636

37-
$this->dispatch(new SimpleJob());
37+
$this->dispatch(new SimpleJob);
3838

3939
CloudTasksApi::assertTaskCreated(function (Task $task) {
4040
return $task->getHttpRequest()->getUrl() === 'https://docker.for.mac.localhost:8080/my-custom-route';
@@ -49,7 +49,7 @@ public function the_handle_route_task_uri_in_combination_with_path_can_be_config
4949
$this->setConfigValue('handler', 'https://example.com/api');
5050
$this->app['config']->set('cloud-tasks.uri', 'my-custom-route');
5151

52-
$this->dispatch(new SimpleJob());
52+
$this->dispatch(new SimpleJob);
5353

5454
CloudTasksApi::assertTaskCreated(function (Task $task) {
5555
return $task->getHttpRequest()->getUrl() === 'https://example.com/api/my-custom-route';

tests/IncomingTaskTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
class IncomingTaskTest extends TestCase
1818
{
19-
public function setUp(): void
19+
protected function setUp(): void
2020
{
2121
parent::setUp();
2222

tests/QueueAppEngineTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function an_app_engine_http_request_with_the_handler_url_is_made()
2525
CloudTasksApi::fake();
2626

2727
// Act
28-
$this->dispatch(new SimpleJob());
28+
$this->dispatch(new SimpleJob);
2929

3030
// Assert
3131
CloudTasksApi::assertTaskCreated(function (Task $task): bool {
@@ -40,7 +40,7 @@ public function it_routes_to_the_service()
4040
CloudTasksApi::fake();
4141

4242
// Act
43-
$this->dispatch(new SimpleJob());
43+
$this->dispatch(new SimpleJob);
4444

4545
// Assert
4646
CloudTasksApi::assertTaskCreated(function (Task $task): bool {
@@ -55,7 +55,7 @@ public function it_contains_the_payload()
5555
CloudTasksApi::fake();
5656

5757
// Act
58-
$this->dispatch($job = new SimpleJob());
58+
$this->dispatch($job = new SimpleJob);
5959

6060
// Assert
6161
CloudTasksApi::assertTaskCreated(function (Task $task) use ($job): bool {

tests/QueueTest.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function a_http_request_with_the_handler_url_is_made()
5050
CloudTasksApi::fake();
5151

5252
// Act
53-
$this->dispatch(new SimpleJob());
53+
$this->dispatch(new SimpleJob);
5454

5555
// Assert
5656
CloudTasksApi::assertTaskCreated(function (Task $task): bool {
@@ -65,7 +65,7 @@ public function it_posts_to_the_handler()
6565
CloudTasksApi::fake();
6666

6767
// Act
68-
$this->dispatch(new SimpleJob());
68+
$this->dispatch(new SimpleJob);
6969

7070
// Assert
7171
CloudTasksApi::assertTaskCreated(function (Task $task): bool {
@@ -81,7 +81,7 @@ public function it_posts_to_the_configured_handler_url()
8181
CloudTasksApi::fake();
8282

8383
// Act
84-
$this->dispatch(new SimpleJob());
84+
$this->dispatch(new SimpleJob);
8585

8686
// Assert
8787
CloudTasksApi::assertTaskCreated(function (Task $task): bool {
@@ -98,7 +98,7 @@ public function it_posts_to_the_callback_handler_url()
9898
CloudTasksQueue::configureHandlerUrlUsing(static fn (SimpleJob $job) => 'https://example.com/api/my-custom-route?job='.$job->id);
9999

100100
// Act
101-
$job = new SimpleJob();
101+
$job = new SimpleJob;
102102
$job->id = 1;
103103
$this->dispatch($job);
104104

@@ -115,7 +115,7 @@ public function it_posts_the_serialized_job_payload_to_the_handler()
115115
CloudTasksApi::fake();
116116

117117
// Act
118-
$this->dispatch($job = new SimpleJob());
118+
$this->dispatch($job = new SimpleJob);
119119

120120
// Assert
121121
CloudTasksApi::assertTaskCreated(function (Task $task) use ($job): bool {
@@ -135,7 +135,7 @@ public function it_will_set_the_scheduled_time_when_dispatching_later()
135135

136136
// Act
137137
$inFiveMinutes = now()->addMinutes(5);
138-
$this->dispatch((new SimpleJob())->delay($inFiveMinutes));
138+
$this->dispatch((new SimpleJob)->delay($inFiveMinutes));
139139

140140
// Assert
141141
CloudTasksApi::assertTaskCreated(function (Task $task) use ($inFiveMinutes): bool {
@@ -153,8 +153,8 @@ public function it_posts_the_task_the_correct_queue()
153153
$closureDisplayName = CallQueuedClosure::create($closure)->displayName();
154154

155155
// Act
156-
$this->dispatch((new SimpleJob()));
157-
$this->dispatch((new FailingJob())->onQueue('my-special-queue'));
156+
$this->dispatch((new SimpleJob));
157+
$this->dispatch((new FailingJob)->onQueue('my-special-queue'));
158158
$this->dispatch($closure);
159159
$this->dispatch($closure, 'my-special-queue');
160160

@@ -248,7 +248,7 @@ public function jobs_can_be_released()
248248
]);
249249

250250
// Act
251-
$this->dispatch(new JobThatWillBeReleased())
251+
$this->dispatch(new JobThatWillBeReleased)
252252
->runAndGetReleasedJob()
253253
->run();
254254

@@ -305,7 +305,7 @@ public function test_default_backoff()
305305
Event::fake(JobReleasedAfterException::class);
306306

307307
// Act
308-
$this->dispatch(new FailingJob())->run();
308+
$this->dispatch(new FailingJob)->run();
309309

310310
// Assert
311311
CloudTasksApi::assertTaskCreated(function (Task $task) {
@@ -323,7 +323,7 @@ public function test_backoff_from_queue_config()
323323
Event::fake(JobReleasedAfterException::class);
324324

325325
// Act
326-
$this->dispatch(new FailingJob())->run();
326+
$this->dispatch(new FailingJob)->run();
327327

328328
// Assert
329329
CloudTasksApi::assertTaskCreated(function (Task $task) {
@@ -341,7 +341,7 @@ public function test_backoff_from_job()
341341
Event::fake(JobReleasedAfterException::class);
342342

343343
// Act
344-
$failingJob = new FailingJob();
344+
$failingJob = new FailingJob;
345345
$failingJob->backoff = 123;
346346
$this->dispatch($failingJob)->run();
347347

@@ -360,7 +360,7 @@ public function test_exponential_backoff_from_job_method()
360360
CloudTasksApi::fake();
361361

362362
// Act
363-
$releasedJob = $this->dispatch(new FailingJobWithExponentialBackoff())
363+
$releasedJob = $this->dispatch(new FailingJobWithExponentialBackoff)
364364
->runAndGetReleasedJob();
365365
$releasedJob = $releasedJob->runAndGetReleasedJob();
366366
$releasedJob->run();
@@ -388,7 +388,7 @@ public function test_failing_method_on_job()
388388
Event::fake(JobOutput::class);
389389

390390
// Act
391-
$this->dispatch(new FailingJob())
391+
$this->dispatch(new FailingJob)
392392
->runAndGetReleasedJob()
393393
->runAndGetReleasedJob()
394394
->runAndGetReleasedJob();
@@ -411,7 +411,7 @@ public function test_queue_before_and_after_hooks()
411411
Queue::after(function (JobProcessed $event) {
412412
event(new JobOutput('Queue::after:'.$event->job->payload()['data']['commandName']));
413413
});
414-
$this->dispatch(new SimpleJob())->run();
414+
$this->dispatch(new SimpleJob)->run();
415415

416416
// Assert
417417
Event::assertDispatched(fn (JobOutput $event) => $event->output === 'Queue::before:Tests\Support\SimpleJob');
@@ -429,7 +429,7 @@ public function test_queue_looping_hook_not_supported_with_this_package()
429429
Queue::looping(function () {
430430
event(new JobOutput('Queue::looping'));
431431
});
432-
$this->dispatch(new SimpleJob())->run();
432+
$this->dispatch(new SimpleJob)->run();
433433

434434
// Assert
435435
Event::assertDispatchedTimes(JobOutput::class, times: 1);
@@ -475,7 +475,7 @@ public function it_adds_a_pre_defined_task_name()
475475
Str::createUlidsUsingSequence(['01HSR4V9QE2F4T0K8RBAYQ88KE']);
476476

477477
// Act
478-
$this->dispatch((new SimpleJob()));
478+
$this->dispatch((new SimpleJob));
479479

480480
// Assert
481481
CloudTasksApi::assertTaskCreated(function (Task $task): bool {
@@ -494,7 +494,7 @@ public function headers_can_be_added_to_the_task()
494494
'X-MyHeader' => 'MyValue',
495495
]);
496496

497-
$this->dispatch((new SimpleJob()));
497+
$this->dispatch((new SimpleJob));
498498

499499
// Assert
500500
CloudTasksApi::assertTaskCreated(function (Task $task): bool {
@@ -513,7 +513,7 @@ public function headers_can_be_added_to_the_task_with_job_context()
513513
'X-MyHeader' => $payload['displayName'],
514514
]);
515515

516-
$this->dispatch((new SimpleJob()));
516+
$this->dispatch((new SimpleJob));
517517

518518
// Assert
519519
CloudTasksApi::assertTaskCreated(function (Task $task): bool {
@@ -529,10 +529,10 @@ public function batched_jobs_with_custom_queue_are_dispatched_on_the_custom_queu
529529

530530
// Act
531531
$this->dispatch(Bus::batch([
532-
tap(new SimpleJob(), function (SimpleJob $job) {
532+
tap(new SimpleJob, function (SimpleJob $job) {
533533
$job->queue = 'my-queue1';
534534
}),
535-
tap(new SimpleJobWithTimeout(), function (SimpleJob $job) {
535+
tap(new SimpleJobWithTimeout, function (SimpleJob $job) {
536536
$job->queue = 'my-queue2';
537537
}),
538538
])->onQueue('my-batch-queue'));

0 commit comments

Comments
 (0)