Skip to content

Commit 97e4d59

Browse files
marickvantuilgithub-actions[bot]
authored andcommitted
Apply code style rules
1 parent d842772 commit 97e4d59

File tree

2 files changed

+24
-23
lines changed

2 files changed

+24
-23
lines changed

src/Commands/WorkCloudRunJob.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
use Exception;
88
use Illuminate\Console\Command;
9+
10+
use function Safe\base64_decode;
11+
912
use Illuminate\Container\Container;
1013
use Illuminate\Queue\WorkerOptions;
1114
use Illuminate\Support\Facades\Storage;
@@ -15,8 +18,6 @@
1518
use Stackkit\LaravelGoogleCloudTasksQueue\CloudTasksJob;
1619
use Stackkit\LaravelGoogleCloudTasksQueue\CloudTasksQueue;
1720

18-
use function Safe\base64_decode;
19-
2021
/**
2122
* Artisan command to process Cloud Tasks jobs via Cloud Run Jobs.
2223
*
@@ -100,7 +101,7 @@ public function handle(): int
100101
$worker = app('cloud-tasks.worker');
101102

102103
// We manually manage retries by releasing jobs (which pushes a new task back to Cloud Tasks),
103-
// so we never want to return a failure exit code as that will result in duplicate job attempts
104+
// so we never want to return a failure exit code as that will result in duplicate job attempts
104105
// if retries are configured on the cloud run job.
105106
rescue(fn () => $worker->process(
106107
connectionName: $job->getConnectionName(),
@@ -180,7 +181,7 @@ private function fetchPayloadFromStorage(string $payloadPath): ?string
180181
*/
181182
private function getWorkerOptions(array $config): WorkerOptions
182183
{
183-
$options = new WorkerOptions();
184+
$options = new WorkerOptions;
184185

185186
if (isset($config['backoff'])) {
186187
$options->backoff = $config['backoff'];

tests/CloudRunJobTest.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function it_can_run_a_job_via_the_command(): void
7878
{
7979
// Arrange
8080
Event::fake(JobOutput::class);
81-
$payload = $this->createPayload(new SimpleJob());
81+
$payload = $this->createPayload(new SimpleJob);
8282
$this->setEnvVars($payload, 'test-task-name');
8383

8484
// Act
@@ -95,7 +95,7 @@ public function it_extracts_connection_from_payload(): void
9595
Event::fake(JobOutput::class);
9696

9797
// Create a job with a specific connection
98-
$job = new SimpleJob();
98+
$job = new SimpleJob;
9999
$job->connection = 'my-cloudtasks-connection';
100100
$payload = $this->createPayload($job);
101101
$this->setEnvVars($payload, 'test-task-name');
@@ -121,7 +121,7 @@ public function it_fails_without_payload(): void
121121
public function it_fails_without_task_name(): void
122122
{
123123
// Arrange
124-
$payload = $this->createPayload(new SimpleJob());
124+
$payload = $this->createPayload(new SimpleJob);
125125
putenv('CLOUD_TASKS_PAYLOAD='.$payload);
126126

127127
// Act & Assert
@@ -143,7 +143,7 @@ public function it_handles_failing_jobs(): void
143143
{
144144
// Arrange
145145
Event::fake(JobOutput::class);
146-
$payload = $this->createPayload(new FailingJob());
146+
$payload = $this->createPayload(new FailingJob);
147147
$this->setEnvVars($payload, 'test-task-name');
148148

149149
// Act & Assert - The command should always return success, just like the HTTP handler.
@@ -158,7 +158,7 @@ public function it_can_handle_encrypted_jobs(): void
158158
{
159159
// Arrange
160160
Event::fake(JobOutput::class);
161-
$payload = $this->createPayload(new EncryptedJob());
161+
$payload = $this->createPayload(new EncryptedJob);
162162
$this->setEnvVars($payload, 'test-task-name');
163163

164164
// Act
@@ -177,7 +177,7 @@ public function uses_worker_options_callback(): void
177177
return new WorkerOptions(maxTries: 10);
178178
});
179179

180-
$payload = $this->createPayload(new SimpleJob());
180+
$payload = $this->createPayload(new SimpleJob);
181181
$this->setEnvVars($payload, 'test-task-name');
182182

183183
// Act
@@ -201,7 +201,7 @@ public function cloud_run_job_target_creates_http_request_to_run_api(): void
201201
$this->setConfigValue('cloud_run_job_region', 'europe-west1');
202202

203203
// Act
204-
$this->dispatch(new SimpleJob());
204+
$this->dispatch(new SimpleJob);
205205

206206
// Assert
207207
CloudTasksApi::assertTaskCreated(function (Task $task): bool {
@@ -221,7 +221,7 @@ public function cloud_run_job_target_uses_location_as_default_region(): void
221221
// Not setting cloud_run_job_region - should default to location
222222

223223
// Act
224-
$this->dispatch(new SimpleJob());
224+
$this->dispatch(new SimpleJob);
225225

226226
// Assert
227227
CloudTasksApi::assertTaskCreated(function (Task $task): bool {
@@ -241,7 +241,7 @@ public function cloud_run_job_target_posts_with_post_method(): void
241241
$this->setConfigValue('cloud_run_job_name', 'my-worker-job');
242242

243243
// Act
244-
$this->dispatch(new SimpleJob());
244+
$this->dispatch(new SimpleJob);
245245

246246
// Assert
247247
CloudTasksApi::assertTaskCreated(function (Task $task): bool {
@@ -258,7 +258,7 @@ public function cloud_run_job_target_includes_container_overrides_with_env_vars(
258258
$this->setConfigValue('cloud_run_job_name', 'my-worker-job');
259259

260260
// Act
261-
$this->dispatch(new SimpleJob());
261+
$this->dispatch(new SimpleJob);
262262

263263
// Assert
264264
CloudTasksApi::assertTaskCreated(function (Task $task): bool {
@@ -278,7 +278,7 @@ public function cloud_run_job_target_includes_base64_encoded_payload_in_env(): v
278278
$this->setConfigValue('cloud_run_job_name', 'my-worker-job');
279279

280280
// Act
281-
$this->dispatch(new SimpleJob());
281+
$this->dispatch(new SimpleJob);
282282

283283
// Assert
284284
CloudTasksApi::assertTaskCreated(function (Task $task): bool {
@@ -307,7 +307,7 @@ public function cloud_run_job_target_includes_task_name_in_env(): void
307307
$this->setConfigValue('cloud_run_job_name', 'my-worker-job');
308308

309309
// Act
310-
$this->dispatch(new SimpleJob());
310+
$this->dispatch(new SimpleJob);
311311

312312
// Assert
313313
CloudTasksApi::assertTaskCreated(function (Task $task): bool {
@@ -334,7 +334,7 @@ public function cloud_run_job_target_sets_oauth_token_with_correct_scope(): void
334334
$this->setConfigValue('cloud_run_job_name', 'my-worker-job');
335335

336336
// Act
337-
$this->dispatch(new SimpleJob());
337+
$this->dispatch(new SimpleJob);
338338

339339
// Assert
340340
CloudTasksApi::assertTaskCreated(function (Task $task): bool {
@@ -354,7 +354,7 @@ public function cloud_run_job_target_respects_dispatch_deadline(): void
354354
$this->setConfigValue('dispatch_deadline', 1800);
355355

356356
// Act
357-
$this->dispatch(new SimpleJob());
357+
$this->dispatch(new SimpleJob);
358358

359359
// Assert
360360
CloudTasksApi::assertTaskCreated(function (Task $task): bool {
@@ -374,7 +374,7 @@ public function incoming_task_returns_task_name_from_constructor(): void
374374
'displayName' => 'SimpleJob',
375375
'job' => 'Illuminate\\Queue\\CallQueuedHandler@call',
376376
'data' => [
377-
'command' => serialize(new SimpleJob()),
377+
'command' => serialize(new SimpleJob),
378378
],
379379
'internal' => [
380380
'attempts' => 0,
@@ -392,7 +392,7 @@ public function incoming_task_returns_task_name_from_constructor(): void
392392
public function incoming_task_extracts_connection_from_payload(): void
393393
{
394394
// Arrange
395-
$job = new SimpleJob();
395+
$job = new SimpleJob;
396396
$job->connection = 'my-cloudtasks-connection';
397397

398398
$payload = json_encode([
@@ -428,7 +428,7 @@ public function payload_below_threshold_is_passed_directly_in_env(): void
428428
$this->setConfigValue('payload_threshold', 100000); // 100KB threshold
429429

430430
// Act
431-
$this->dispatch(new SimpleJob());
431+
$this->dispatch(new SimpleJob);
432432

433433
// Assert - should use CLOUD_TASKS_PAYLOAD directly since payload is below threshold
434434
CloudTasksApi::assertTaskCreated(function (Task $task): bool {
@@ -458,7 +458,7 @@ public function payload_above_threshold_is_stored_in_disk(): void
458458
$this->setConfigValue('payload_threshold', 1); // 1 byte threshold
459459

460460
// Act
461-
$this->dispatch(new SimpleJob());
461+
$this->dispatch(new SimpleJob);
462462

463463
// Assert - should use CLOUD_TASKS_PAYLOAD_PATH since payload exceeds threshold
464464
CloudTasksApi::assertTaskCreated(function (Task $task): bool {
@@ -485,7 +485,7 @@ public function worker_can_process_job_from_payload_path(): void
485485
// Arrange
486486
Event::fake(JobOutput::class);
487487
Storage::fake('local');
488-
$payload = $this->createPayload(new SimpleJob());
488+
$payload = $this->createPayload(new SimpleJob);
489489
$path = 'cloud-tasks-payloads/test-task.json';
490490

491491
// Store payload in fake storage

0 commit comments

Comments
 (0)