diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index be78efd4..e3c02078 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -20,6 +20,7 @@ jobs: os: [ubuntu-latest, windows-latest] php: [8.5, 8.4] laravel: [13.*, 12.*] + permission: ['^8.3'] stability: [prefer-stable] include: - laravel: 13.* @@ -28,8 +29,22 @@ jobs: - laravel: 12.* testbench: 10.* carbon: '>=3.8.4 <4.0' + - os: ubuntu-latest + php: 8.4 + laravel: 13.* + testbench: 11.* + carbon: '>=3.8.4 <4.0' + permission: '^7.0' + stability: prefer-stable + - os: ubuntu-latest + php: 8.4 + laravel: 12.* + testbench: 10.* + carbon: '>=3.8.4 <4.0' + permission: '^7.0' + stability: prefer-stable - name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} + name: P${{ matrix.php }} - L${{ matrix.laravel }} - Permission ${{ matrix.permission }} - ${{ matrix.stability }} - ${{ matrix.os }} steps: - name: Checkout code @@ -51,6 +66,7 @@ jobs: run: | composer config audit.block-insecure false composer require --dev "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "nesbot/carbon:${{ matrix.carbon }}" --no-interaction --no-update + composer require "spatie/laravel-permission:${{ matrix.permission }}" --no-interaction --no-update composer update --${{ matrix.stability }} --prefer-dist --no-interaction - name: List Installed Dependencies diff --git a/composer.json b/composer.json index e9119677..6c671293 100644 --- a/composer.json +++ b/composer.json @@ -47,7 +47,7 @@ "illuminate/contracts": "^12.0|^13.0", "livewire/livewire": "^3.0|^4.0", "spatie/laravel-package-tools": "^1.14.0", - "spatie/laravel-permission": "^7.0", + "spatie/laravel-permission": "^7.0|^8.3", "step2dev/lazy-breadcrumb": "dev-main", "step2dev/lazy-setting": "dev-main", "step2dev/lazy-ui": "dev-2.x-dev", diff --git a/tests/Feature/SpatiePermissionCompatibilityTest.php b/tests/Feature/SpatiePermissionCompatibilityTest.php new file mode 100644 index 00000000..042c716a --- /dev/null +++ b/tests/Feature/SpatiePermissionCompatibilityTest.php @@ -0,0 +1,28 @@ +not->toBeNull() + ->and(version_compare(ltrim((string) $version, 'v'), '7.0.0', '>='))->toBeTrue() + ->and(app(AuthorizationManager::class)->roleModel())->toBe(Role::class) + ->and(app(AuthorizationManager::class)->permissionModel())->toBe(Permission::class); +}); + +it('keeps the package constraint compatible with existing v7 installs while allowing v8', function (): void { + $composer = json_decode( + file_get_contents(dirname(__DIR__, 2).'/composer.json'), + true, + 512, + JSON_THROW_ON_ERROR, + ); + + expect($composer['require']['spatie/laravel-permission'] ?? null)->toBe('^7.0|^8.3'); +});