From d5c2ca544f40d85f877b38eb6d23e9c967ecb69f Mon Sep 17 00:00:00 2001 From: Patrick O'Meara Date: Wed, 13 Mar 2024 23:47:32 +1100 Subject: [PATCH] Support Laravel 11 (#273) Co-authored-by: Loris Leiva --- .github/workflows/php-cs-fixer.yml | 4 +- .github/workflows/run-tests.yml | 16 ++++---- .gitignore | 2 +- composer.json | 12 +++--- phpunit.xml.dist | 60 +++++++++++++----------------- tests/AsJobWithBatchTest.php | 7 +++- 6 files changed, 49 insertions(+), 52 deletions(-) diff --git a/.github/workflows/php-cs-fixer.yml b/.github/workflows/php-cs-fixer.yml index f55d1fa..01de9df 100644 --- a/.github/workflows/php-cs-fixer.yml +++ b/.github/workflows/php-cs-fixer.yml @@ -8,7 +8,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: ref: ${{ github.head_ref }} @@ -18,6 +18,6 @@ jobs: args: --config=.php_cs.dist.php --allow-risky=yes - name: Commit changes - uses: stefanzweifel/git-auto-commit-action@v4 + uses: stefanzweifel/git-auto-commit-action@v5 with: commit_message: Fix styling diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 077915b..9447748 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -9,25 +9,25 @@ jobs: fail-fast: true matrix: os: [ubuntu-latest] - php: ["8.0", "8.1", "8.2"] - laravel: ["^9.0", "^10.0"] + php: ["8.1", "8.2", "8.3"] + laravel: ["^10.0", "^11.0"] dependency-version: [prefer-lowest, prefer-stable] include: - - laravel: "^9.0" - testbench: "^7.0" - laravel: "^10.0" testbench: "^8.0" + - laravel: "^11.0" + testbench: "^9.0" exclude: - - php: "8.2" - laravel: "^9.0" - - php: "8.0" + - php: "8.3" laravel: "^10.0" + - php: "8.1" + laravel: "^11.0" name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} - ${{ matrix.os }} steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup PHP uses: shivammathur/setup-php@v2 diff --git a/.gitignore b/.gitignore index adc6804..81bd39d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ .idea .php_cs .php_cs.cache -.phpunit.result.cache +.phpunit* build composer.lock coverage diff --git a/composer.json b/composer.json index 3c5ec5f..174d954 100644 --- a/composer.json +++ b/composer.json @@ -21,14 +21,14 @@ } ], "require": { - "php": "^8.0", - "illuminate/contracts": "9.0 - 9.34 || ^9.36 || ^10.0", - "lorisleiva/lody": "^0.4" + "php": "^8.1", + "illuminate/contracts": "^10.0|^11.0", + "lorisleiva/lody": "^0.5" }, "require-dev": { - "orchestra/testbench": "^8.5", - "pestphp/pest": "^1.23", - "phpunit/phpunit": "^9.6" + "orchestra/testbench": "^9.0", + "pestphp/pest": "^1.23|^2.34", + "phpunit/phpunit": "^9.6|^10.0" }, "autoload": { "psr-4": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 05f3d81..12e7a6c 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,36 +1,28 @@ - - - - tests - - - - - ./src - - - - - - - - - - - - - - - + + + + tests + + + + + + + + + + + + + + + + + + + + ./src + + diff --git a/tests/AsJobWithBatchTest.php b/tests/AsJobWithBatchTest.php index 71929c2..a318ff5 100644 --- a/tests/AsJobWithBatchTest.php +++ b/tests/AsJobWithBatchTest.php @@ -5,6 +5,7 @@ use Illuminate\Bus\Batch; use Illuminate\Support\Facades\Bus; use Illuminate\Support\Facades\Schema; +use Illuminate\Support\Str; use Lorisleiva\Actions\Concerns\AsJob; class AsJobWithBatchTest @@ -44,7 +45,11 @@ public function asJob(?Batch $batch, int $left, int $right) // And have a `job_batches` table. $this->artisan('migrate')->run(); if (! Schema::hasTable('job_batches')) { - $this->artisan('queue:batches-table')->run(); + if (Str::startsWith($this->app->version(), "11.")) { + $this->artisan('make:queue-batches-table')->run(); + } else { + $this->artisan('queue:batches-table')->run(); + } $this->artisan('migrate')->run(); } });