Skip to content

Commit

Permalink
Support Laravel 11 (#273)
Browse files Browse the repository at this point in the history
Co-authored-by: Loris Leiva <loris.leiva@gmail.com>
  • Loading branch information
patrickomeara and lorisleiva committed Mar 13, 2024
1 parent 5d2e2a6 commit d5c2ca5
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 52 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/php-cs-fixer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}

Expand All @@ -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
16 changes: 8 additions & 8 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.idea
.php_cs
.php_cs.cache
.phpunit.result.cache
.phpunit*
build
composer.lock
coverage
Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
60 changes: 26 additions & 34 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,36 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
verbose="true"
>
<testsuites>
<testsuite name="Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory suffix=".php">./src</directory>
</include>
<report>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
<clover outputFile="build/logs/clover.xml"/>
</report>
</coverage>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<php>
<env name="APP_ENV" value="testing"/>
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
</php>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<report>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
<clover outputFile="build/logs/clover.xml"/>
</report>
</coverage>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<php>
<env name="APP_ENV" value="testing"/>
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
</php>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
7 changes: 6 additions & 1 deletion tests/AsJobWithBatchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
}
});
Expand Down

0 comments on commit d5c2ca5

Please sign in to comment.