Skip to content

Commit c1f2b2d

Browse files
committed
Drop support for Laravel 6, 7, 8 and 9
1 parent ac6db5e commit c1f2b2d

11 files changed

+29
-180
lines changed

.github/workflows/run-tests.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,6 @@ jobs:
6767
- { queue: 'github-actions-laravel10-php83', laravel: '10.*', php: '8.3', 'testbench': '8.*'}
6868
- { queue: 'github-actions-laravel10-php82', laravel: '10.*', php: '8.2', 'testbench': '8.*'}
6969
- { queue: 'github-actions-laravel10-php81', laravel: '10.*', php: '8.1', 'testbench': '8.*'}
70-
- { queue: 'github-actions-laravel9-php83', laravel: '9.*', php: '8.3', 'testbench': '7.*'}
71-
- { queue: 'github-actions-laravel9-php82', laravel: '9.*', php: '8.2', 'testbench': '7.*'}
72-
- { queue: 'github-actions-laravel9-php81', laravel: '9.*', php: '8.1', 'testbench': '7.*'}
73-
- { queue: 'github-actions-laravel9-php80', laravel: '9.*', php: '8.0', 'testbench': '7.*'}
74-
- { queue: 'github-actions-laravel8-php81', laravel: '8.*', php: '8.1', 'testbench': '6.*'}
75-
- { queue: 'github-actions-laravel8-php80', laravel: '8.*', php: '8.0', 'testbench': '6.*'}
76-
- { queue: 'github-actions-laravel8-php74', laravel: '8.*', php: '7.4', 'testbench': '6.*'}
77-
- { queue: 'github-actions-laravel7-php80', laravel: '7.*', php: '8.0', 'testbench': '5.*' }
78-
- { queue: 'github-actions-laravel7-php74', laravel: '7.*', php: '7.4', 'testbench': '5.*' }
79-
- { queue: 'github-actions-laravel6-php80', laravel: '6.*', php: '8.0', 'testbench': '4.*' }
80-
- { queue: 'github-actions-laravel6-php74', laravel: '6.*', php: '7.4', 'testbench': '4.*' }
8170

8271
name: PHP ${{ matrix.payload.php }} - Laravel ${{ matrix.payload.laravel }} - DB ${{ matrix.db }}
8372

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ This package allows Google Cloud Tasks to be used as the queue driver.
2121
</summary>
2222

2323
<br>
24-
This package requires Laravel 6 or higher and supports MySQL 8 and PostgreSQL 14. Might support older database versions too, but package hasn't been tested for it.
24+
This package requires Laravel 10 or higher and supports MySQL 8 and PostgreSQL 15. Might support older database versions too, but package hasn't been tested for it.
2525

2626
Please check the [Laravel support policy](https://laravel.com/docs/master/releases#support-policy) table for supported Laravel and PHP versions.
2727
</details>

composer.json

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"thecodingmachine/safe": "^1.0|^2.0"
1616
},
1717
"require-dev": {
18-
"orchestra/testbench": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0",
18+
"orchestra/testbench": "^8.0",
1919
"nunomaduro/larastan": "^1.0 || ^2.0",
2020
"thecodingmachine/phpstan-safe-rule": "^1.2",
2121
"laravel/legacy-factories": "^1.3"
@@ -45,21 +45,5 @@
4545
"composer require laravel/framework:10.* orchestra/testbench:8.* --no-interaction --no-update",
4646
"composer update --prefer-stable --prefer-dist --no-interaction"
4747
],
48-
"l9": [
49-
"composer require laravel/framework:9.* orchestra/testbench:7.* --no-interaction --no-update",
50-
"composer update --prefer-stable --prefer-dist --no-interaction"
51-
],
52-
"l8": [
53-
"composer require laravel/framework:8.* orchestra/testbench:6.* --no-interaction --no-update",
54-
"composer update --prefer-stable --prefer-dist --no-interaction"
55-
],
56-
"l7": [
57-
"composer require laravel/framework:7.* orchestra/testbench:5.* --no-interaction --no-update",
58-
"composer update --prefer-stable --prefer-dist --no-interaction"
59-
],
60-
"l6": [
61-
"composer require laravel/framework:6.* orchestra/testbench:4.* --no-interaction --no-update",
62-
"composer update --prefer-stable --prefer-dist --no-interaction"
63-
]
6448
}
6549
}

src/CloudTasksJob.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use Illuminate\Contracts\Queue\Job as JobContract;
77
use Illuminate\Queue\Jobs\Job as LaravelJob;
88
use Stackkit\LaravelGoogleCloudTasksQueue\Events\JobReleased;
9-
use Stackkit\LaravelGoogleCloudTasksQueue\Events\JobReleasedAfterException;
109
use function Safe\json_encode;
1110

1211
class CloudTasksJob extends LaravelJob implements JobContract
@@ -137,16 +136,6 @@ public function release($delay = 0)
137136
$properties = TaskHandler::getCommandProperties($this->job['data']['command']);
138137
$connection = $properties['connection'] ?? config('queue.default');
139138

140-
// The package uses the JobReleasedAfterException provided by Laravel to grab
141-
// the payload of the released job in tests to easily run and test a released
142-
// job. Because the event is only accessible in Laravel 9.x, we create an
143-
// identical event to hook into for Laravel versions older than 9.x
144-
if (version_compare(app()->version(), '9.0.0', '<')) {
145-
if (data_get($this->job, 'internal.errored')) {
146-
app('events')->dispatch(new JobReleasedAfterException($connection, $this));
147-
}
148-
}
149-
150139
if (! data_get($this->job, 'internal.errored')) {
151140
app('events')->dispatch(new JobReleased($connection, $this, $delay));
152141
}

src/CloudTasksQueue.php

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -48,25 +48,6 @@ public function size($queue = null)
4848
return 0;
4949
}
5050

51-
/**
52-
* Fallback method for Laravel 6x and 7x
53-
*
54-
* @param \Closure|string|object $job
55-
* @param string $payload
56-
* @param string $queue
57-
* @param \DateTimeInterface|\DateInterval|int|null $delay
58-
* @param callable $callback
59-
* @return mixed
60-
*/
61-
protected function enqueueUsing($job, $payload, $queue, $delay, $callback)
62-
{
63-
if (method_exists(parent::class, 'enqueueUsing')) {
64-
return parent::enqueueUsing($job, $payload, $queue, $delay, $callback);
65-
}
66-
67-
return $callback($payload, $queue, $delay);
68-
}
69-
7051
/**
7152
* Push a new job onto the queue.
7253
*
@@ -141,11 +122,6 @@ protected function pushToCloudTasks($queue, $payload, $delay = 0)
141122

142123
$payload = json_decode($payload, true);
143124

144-
// Laravel 7+ jobs have a uuid, but Laravel 6 doesn't have it.
145-
// Since we are using and expecting the uuid in some places
146-
// we will add it manually here if it's not present yet.
147-
$payload = $this->withUuid($payload);
148-
149125
// Since 3.x tasks are released back onto the queue after an exception has
150126
// been thrown. This means we lose the native [X-CloudTasks-TaskRetryCount] header
151127
// value and need to manually set and update the number of times a task has been attempted.
@@ -202,15 +178,6 @@ protected function pushToCloudTasks($queue, $payload, $delay = 0)
202178
return $payload['uuid'];
203179
}
204180

205-
private function withUuid(array $payload): array
206-
{
207-
if (!isset($payload['uuid'])) {
208-
$payload['uuid'] = (string)Str::uuid();
209-
}
210-
211-
return $payload;
212-
}
213-
214181
private function taskName(string $queueName, array $payload): string
215182
{
216183
$displayName = $this->sanitizeTaskName($payload['displayName']);

src/Events/JobReleasedAfterException.php

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/TaskHandler.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,9 @@ public function getWorkerOptions(): WorkerOptions
200200
{
201201
$options = new WorkerOptions();
202202

203-
$prop = version_compare(app()->version(), '8.0.0', '<') ? 'delay' : 'backoff';
204-
205-
$options->$prop = $this->config['backoff'] ?? 0;
203+
if (isset($this->config['backoff'])) {
204+
$options->backoff = $this->config['backoff'];
205+
}
206206

207207
return $options;
208208
}

tests/CloudTasksDashboardTest.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -527,17 +527,11 @@ public function test_publish()
527527
// Act & Assert
528528
$expectedPublishBase = dirname(__DIR__);
529529

530-
if (version_compare(app()->version(), '9.0.0', '>=')) {
531-
$this->artisan('vendor:publish --tag=cloud-tasks --force')
532-
->expectsOutputToContain('Publishing [cloud-tasks] assets.')
533-
->expectsOutputToContain('Copying file [' . $expectedPublishBase . '/config/cloud-tasks.php] to [config/cloud-tasks.php]')
534-
->expectsOutputToContain('Copying directory [' . $expectedPublishBase . '/dashboard/dist] to [public/vendor/cloud-tasks]');
535-
} else {
536-
$this->artisan('vendor:publish --tag=cloud-tasks --force')
537-
->expectsOutput('Copied File [' . $expectedPublishBase . '/config/cloud-tasks.php] To [/config/cloud-tasks.php]')
538-
->expectsOutput('Copied Directory [' . $expectedPublishBase . '/dashboard/dist] To [/public/vendor/cloud-tasks]')
539-
->expectsOutput('Publishing complete.');
540-
}
530+
$this->artisan('vendor:publish --tag=cloud-tasks --force')
531+
->expectsOutputToContain('Publishing [cloud-tasks] assets.')
532+
->expectsOutputToContain('Copying file [' . $expectedPublishBase . '/config/cloud-tasks.php] to [config/cloud-tasks.php]')
533+
->expectsOutputToContain('Copying directory [' . $expectedPublishBase . '/dashboard/dist] to [public/vendor/cloud-tasks]');
534+
541535
}
542536

543537
/**

tests/QueueTest.php

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Illuminate\Queue\Events\JobProcessed;
1111
use Illuminate\Queue\Events\JobProcessing;
1212
use Illuminate\Queue\Events\JobQueued;
13+
use Illuminate\Queue\Events\JobReleasedAfterException;
1314
use Illuminate\Support\Carbon;
1415
use Illuminate\Support\Facades\DB;
1516
use Illuminate\Support\Facades\Event;
@@ -176,10 +177,6 @@ public function it_posts_the_task_the_correct_queue()
176177
*/
177178
public function it_can_dispatch_after_commit_inline()
178179
{
179-
if (version_compare(app()->version(), '8.0.0', '<')) {
180-
$this->markTestSkipped('Not supported by Laravel 7.x and below.');
181-
}
182-
183180
// Arrange
184181
CloudTasksApi::fake();
185182
Event::fake();
@@ -202,10 +199,6 @@ public function it_can_dispatch_after_commit_inline()
202199
*/
203200
public function it_can_dispatch_after_commit_through_config()
204201
{
205-
if (version_compare(app()->version(), '8.0.0', '<')) {
206-
$this->markTestSkipped('Not supported by Laravel 7.x and below.');
207-
}
208-
209202
// Arrange
210203
CloudTasksApi::fake();
211204
Event::fake();
@@ -233,15 +226,15 @@ public function jobs_can_be_released()
233226
CloudTasksApi::fake();
234227
OpenIdVerificator::fake();
235228
Event::fake([
236-
$this->getJobReleasedAfterExceptionEvent(),
229+
JobReleasedAfterException::class,
237230
JobReleased::class,
238231
]);
239232

240233
// Act
241234
$this->dispatch(new JobThatWillBeReleased())->run();
242235

243236
// Assert
244-
Event::assertNotDispatched($this->getJobReleasedAfterExceptionEvent());
237+
Event::assertNotDispatched(JobReleasedAfterException::class);
245238
CloudTasksApi::assertDeletedTaskCount(0); // it returned 200 OK so we dont delete it, but Google does
246239
$releasedJob = null;
247240
Event::assertDispatched(JobReleased::class, function (JobReleased $event) use (&$releasedJob) {
@@ -275,7 +268,7 @@ public function jobs_can_be_released_with_a_delay()
275268
CloudTasksApi::fake();
276269
OpenIdVerificator::fake();
277270
Event::fake([
278-
$this->getJobReleasedAfterExceptionEvent(),
271+
JobReleasedAfterException::class,
279272
JobReleased::class,
280273
]);
281274
Carbon::setTestNow(now()->addDay());
@@ -302,7 +295,7 @@ public function test_default_backoff()
302295
// Arrange
303296
CloudTasksApi::fake();
304297
OpenIdVerificator::fake();
305-
Event::fake($this->getJobReleasedAfterExceptionEvent());
298+
Event::fake(JobReleasedAfterException::class);
306299

307300
// Act
308301
$this->dispatch(new FailingJob())->run();
@@ -321,7 +314,7 @@ public function test_backoff_from_queue_config()
321314
$this->setConfigValue('backoff', 123);
322315
CloudTasksApi::fake();
323316
OpenIdVerificator::fake();
324-
Event::fake($this->getJobReleasedAfterExceptionEvent());
317+
Event::fake(JobReleasedAfterException::class);
325318

326319
// Act
327320
$this->dispatch(new FailingJob())->run();
@@ -340,12 +333,11 @@ public function test_backoff_from_job()
340333
Carbon::setTestNow(now()->addDay());
341334
CloudTasksApi::fake();
342335
OpenIdVerificator::fake();
343-
Event::fake($this->getJobReleasedAfterExceptionEvent());
336+
Event::fake(JobReleasedAfterException::class);
344337

345338
// Act
346339
$failingJob = new FailingJob();
347-
$prop = version_compare(app()->version(), '8.0.0', '<') ? 'delay' : 'backoff';
348-
$failingJob->$prop = 123;
340+
$failingJob->backoff = 123;
349341
$this->dispatch($failingJob)->run();
350342

351343
// Assert
@@ -358,10 +350,6 @@ public function test_backoff_from_job()
358350
/** @test */
359351
public function test_exponential_backoff_from_job_method()
360352
{
361-
if (version_compare(app()->version(), '8.0.0', '<')) {
362-
$this->markTestSkipped('Not supported by Laravel 7.x and below.');
363-
}
364-
365353
// Arrange
366354
Carbon::setTestNow(now()->addDay());
367355
CloudTasksApi::fake();

0 commit comments

Comments
 (0)