Skip to content

Commit

Permalink
Laravel 12.x Compatibility (#651)
Browse files Browse the repository at this point in the history
  • Loading branch information
laravel-shift authored Feb 21, 2025
1 parent 99be3d7 commit 7fab8a2
Show file tree
Hide file tree
Showing 95 changed files with 477 additions and 644 deletions.
28 changes: 15 additions & 13 deletions .github/workflows/run-stub-tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: run-stub-tests

on: [push, pull_request]
on:
- push
- pull_request

jobs:
stub-test:
Expand All @@ -11,7 +13,7 @@ jobs:
matrix:
os: [ubuntu-22.04, windows-latest]
php: [8.4, 8.3, 8.2]
laravel: [11.0, 10.2]
laravel: [10.2, 11.0]
exclude:
- php: 8.4
laravel: 10.0
Expand All @@ -33,17 +35,17 @@ jobs:
- name: Remove installed Splade (Unix)
run: rm -rf vendor/protonemedia/laravel-splade
if: matrix.os == 'ubuntu-22.04'
if: "matrix.os == 'ubuntu-22.04'"

- name: Remove installed Splade (Windows)
run: rd "vendor/protonemedia/laravel-splade" /s /q
shell: cmd
if: matrix.os == 'windows-latest'
if: "matrix.os == 'windows-latest'"

- name: Checkout code
uses: actions/[email protected]
with:
path: "vendor/protonemedia/laravel-splade"
path: vendor/protonemedia/laravel-splade

- name: Install Splade
run: |
Expand All @@ -59,47 +61,47 @@ jobs:
run: |
rm -rf node_modules/@protonemedia/laravel-splade/dist
cp -R vendor/protonemedia/laravel-splade/dist node_modules/@protonemedia/laravel-splade/
if: matrix.os == 'ubuntu-22.04'
if: "matrix.os == 'ubuntu-22.04'"

- name: Remove installed Splade and copy front-end build from Checkout (Windows)
run: |
rd "node_modules/@protonemedia/laravel-splade/dist" /s /q
mkdir "node_modules/@protonemedia/laravel-splade/dist"
xcopy "vendor/protonemedia/laravel-splade/dist" "node_modules/@protonemedia/laravel-splade/dist" /E /I
shell: cmd
if: matrix.os == 'windows-latest'
if: "matrix.os == 'windows-latest'"

- name: Compile assets
run: npm run build

- name: Run Laravel Server (Unix)
run: php artisan serve &
if: matrix.os == 'ubuntu-22.04'
if: "matrix.os == 'ubuntu-22.04'"

- name: Run Test (Unix)
run: php vendor/protonemedia/laravel-splade/TestStubs.php
if: matrix.os == 'ubuntu-22.04'
if: "matrix.os == 'ubuntu-22.04'"

- name: Run Laravel Server (Windows) and Run Test
run: |
start /b cmd /v:on /c "(php artisan serve) &"
php vendor/protonemedia/laravel-splade/TestStubs.php
shell: cmd
if: matrix.os == 'windows-latest'
if: "matrix.os == 'windows-latest'"

- name: Start SSR server (Unix)
run: |
echo "SPLADE_SSR_ENABLED=true" >> .env
node bootstrap/ssr/ssr.js &
if: matrix.os == 'ubuntu-22.04'
if: "matrix.os == 'ubuntu-22.04'"

- name: Run Test command (Unix)
run: php artisan splade:ssr-test
if: matrix.os == 'ubuntu-22.04'
if: "matrix.os == 'ubuntu-22.04'"

- name: Start SSR server (Windows) and Run Test command
run: |
echo "SPLADE_SSR_ENABLED=true" >> .env
node bootstrap/ssr/ssr.js &
php artisan splade:ssr-test
if: matrix.os == 'windows-latest'
if: "matrix.os == 'windows-latest'"
35 changes: 20 additions & 15 deletions .github/workflows/run-table-tests.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
name: run-table-tests

on: [push, pull_request]
on:
- push
- pull_request

jobs:
table-test:
runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
php: [8.4, 8.3, 8.2]
laravel: [11.0, 10.0]
laravel: [10.0, 11.0, 12.0]
db: [mysql, postgres, sqlite]
ssr: [true, false]
dependency-version: [prefer-lowest, prefer-stable]
include:
- laravel: 12.0
testbench: 10.*
- laravel: 11.0
testbench: 9.*
- laravel: 10.0
testbench: 8.*

exclude:
- dependency-version: prefer-lowest
ssr: true
Expand Down Expand Up @@ -68,20 +74,19 @@ jobs:
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- if: ${{ steps.cache-npm.outputs.cache-hit == 'false' }}
- if: "${{ steps.cache-npm.outputs.cache-hit == 'false' }}"
name: List the state of node modules
continue-on-error: true
run: npm list

- name: "Install locked dependencies with npm"
- name: Install locked dependencies with npm
run: |
npm ci --ignore-scripts
Expand All @@ -99,19 +104,19 @@ jobs:
coverage: none

- name: Prepare environment file (MySQL)
if: ${{ matrix.db == 'mysql' }}
if: "${{ matrix.db == 'mysql' }}"
run: |
cd app
cp .env.example.mysql .env
- name: Prepare environment file (PostgreSQL)
if: ${{ matrix.db == 'postgres' }}
if: "${{ matrix.db == 'postgres' }}"
run: |
cd app
cp .env.example.postgres .env
- name: Prepare environment file (SQLite)
if: ${{ matrix.db == 'sqlite' }}
if: "${{ matrix.db == 'sqlite' }}"
run: |
cd app
cp .env.example .env
Expand Down Expand Up @@ -140,15 +145,15 @@ jobs:
cd app
sed -i -e "s|SPLADE_SSR_ENABLED=false|SPLADE_SSR_ENABLED=true|g" .env
node bootstrap/ssr/ssr.mjs &
if: matrix.ssr == true
if: "matrix.ssr == true"

- name: Migrate DB and Run Laravel Server (MySQL)
run: |
cd app
php artisan storage:link
php artisan migrate:fresh --seed
php artisan serve &
if: ${{ matrix.db == 'mysql' }}
if: "${{ matrix.db == 'mysql' }}"
env:
DB_PORT: ${{ job.services.mysql.ports[3306] }}

Expand All @@ -158,20 +163,20 @@ jobs:
php artisan storage:link
php artisan migrate:fresh --seed
php artisan serve &
if: ${{ matrix.db == 'postgres' }}
if: "${{ matrix.db == 'postgres' }}"
env:
DB_PORT: ${{ job.services.postgres.ports[5432] }}

- name: Migrate DB and Run Laravel Server (SQLite)
if: ${{ matrix.db == 'sqlite' }}
if: "${{ matrix.db == 'sqlite' }}"
run: |
cd app
php artisan storage:link
php artisan migrate:fresh --seed
php artisan serve &
- name: Execute Dusk tests (only table tests - MySQL)
if: ${{ matrix.db == 'mysql' }}
if: "${{ matrix.db == 'mysql' }}"
uses: nick-invision/retry@v3
with:
timeout_minutes: 10
Expand All @@ -182,7 +187,7 @@ jobs:
DB_PORT: ${{ job.services.mysql.ports[3306] }}

- name: Execute Dusk tests (only table tests - PostgreSQL)
if: ${{ matrix.db == 'postgres' }}
if: "${{ matrix.db == 'postgres' }}"
uses: nick-invision/retry@v3
with:
timeout_minutes: 10
Expand All @@ -193,7 +198,7 @@ jobs:
DB_PORT: ${{ job.services.postgres.ports[5432] }}

- name: Execute Dusk tests (only table tests - SQLite)
if: ${{ matrix.db == 'sqlite' }}
if: "${{ matrix.db == 'sqlite' }}"
uses: nick-invision/retry@v3
with:
timeout_minutes: 10
Expand Down
20 changes: 12 additions & 8 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
name: run-tests

on: [push, pull_request]
on:
- push
- pull_request

jobs:
test:
runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
php: [8.4, 8.3, 8.2]
laravel: [11.0, 10.0]
laravel: [10.0, 11.0, 12.0]
ssr: [true, false]
dependency-version: [prefer-lowest, prefer-stable]
include:
- laravel: 12.0
testbench: 10.*
- laravel: 11.0
testbench: 9.*
- laravel: 10.0
Expand All @@ -39,20 +44,19 @@ jobs:
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- if: ${{ steps.cache-npm.outputs.cache-hit == 'false' }}
- if: "${{ steps.cache-npm.outputs.cache-hit == 'false' }}"
name: List the state of node modules
continue-on-error: true
run: npm list

- name: "Install locked dependencies with npm"
- name: Install locked dependencies with npm
run: |
npm ci --ignore-scripts
Expand Down Expand Up @@ -83,15 +87,15 @@ jobs:
php artisan migrate:fresh --seed
- name: Prepare L10
if: ${{ matrix.laravel == '10.0' }}
if: "${{ matrix.laravel == '10.0' }}"
run: |
cd app
rm composer.lock
composer require illuminate/contracts:^10.48.2 spatie/phpunit-snapshot-assertions:^5.0 phpunit/phpunit:^10.4 nunomaduro/collision:^7.10 --no-interaction --no-suggest
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest
- name: Prepare L11
if: ${{ matrix.laravel == '11.0' }}
if: "${{ matrix.laravel == '11.0' }}"
run: |
cd app
rm composer.lock
Expand Down Expand Up @@ -119,7 +123,7 @@ jobs:
cd app
sed -i -e "s|SPLADE_SSR_ENABLED=false|SPLADE_SSR_ENABLED=true|g" .env
node bootstrap/ssr/ssr.mjs &
if: matrix.ssr == true
if: "matrix.ssr == true"

- name: Run Laravel Server
run: |
Expand Down
2 changes: 0 additions & 2 deletions app/app/Models/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Kirschbaum\PowerJoins\PowerJoins;

class Project extends Model
{
use HasFactory;
use PowerJoins;

protected $guarded = [];

Expand Down
10 changes: 5 additions & 5 deletions app/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@
"require": {
"php": "^8.4|^8.3|^8.2",
"guzzlehttp/guzzle": "^7.2",
"kirschbaum-development/eloquent-power-joins": "^3.0",
"laravel/framework": "^10.48.23|^11.33",
"kirschbaum-development/eloquent-power-joins": "^4.0",
"laravel/framework": "^10.48.23|^11.33|^12.0",
"laravel/reverb": "^1.4.3",
"laravel/sanctum": "^3.2|^4.0",
"laravel/tinker": "^2.7",
"maatwebsite/excel": "^3.1",
"monolog/monolog": "^3.0",
"nesbot/carbon": "^2.63",
"nesbot/carbon": "^2.63|^3.0",
"psr/simple-cache": "^2.0",
"ramsey/collection": "^1.2",
"spatie/laravel-medialibrary": "^11.0",
"spatie/laravel-query-builder": "^5.0"
"spatie/laravel-query-builder": "^5.0|^6.0|dev-main"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.7",
"fakerphp/faker": "^1.9.1",
"laravel/dusk": "^8.2.11",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^7.10|^8.1",
"phpunit/phpunit": "^10.4",
"phpunit/phpunit": "^10.4|^11.5.3",
"protonemedia/laravel-splade": "*",
"spatie/ignition": "^1.4.1",
"spatie/invade": "^1.1",
Expand Down
2 changes: 1 addition & 1 deletion app/tests/Browser/AuthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class AuthTest extends DuskTestCase
{
/** @test */
#[\PHPUnit\Framework\Attributes\Test]
public function it_handles_the_login_redirect()
{
$this->browse(function (Browser $browser) {
Expand Down
2 changes: 1 addition & 1 deletion app/tests/Browser/Bridge/InlineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class InlineTest extends DuskTestCase
{
/** @test */
#[\PHPUnit\Framework\Attributes\Test]
public function it_supports_inline_templates()
{
$this->browse(function (Browser $browser) {
Expand Down
6 changes: 3 additions & 3 deletions app/tests/Browser/Bridge/MethodTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class MethodTest extends DuskTestCase
{
/** @test */
#[\PHPUnit\Framework\Attributes\Test]
public function it_can_call_a_php_method_without_losing_state()
{
$this->browse(function (Browser $browser) {
Expand All @@ -24,7 +24,7 @@ public function it_can_call_a_php_method_without_losing_state()
});
}

/** @test */
#[\PHPUnit\Framework\Attributes\Test]
public function it_can_call_a_php_method_with_arguments()
{
$this->browse(function (Browser $browser) {
Expand All @@ -40,7 +40,7 @@ public function it_can_call_a_php_method_with_arguments()
});
}

/** @test */
#[\PHPUnit\Framework\Attributes\Test]
public function it_can_save_eloquent_models_and_refresh_the_state()
{
$this->browse(function (Browser $browser) {
Expand Down
Loading

0 comments on commit 7fab8a2

Please sign in to comment.