Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel 11.x Compatibility #62

Merged
merged 6 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions .github/workflows/ci-phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,30 @@ on:
jobs:
run-tests:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
php: [8.0, 8.1, 8.2]
laravel: [8.*, 9.*, 10.*]
php: [8.0, 8.1, 8.2, 8.3]
laravel: ['8.*', '9.*', '10.*', '11.*']
include:
- laravel: 10.*
testbench: 8.*
- laravel: 9.*
testbench: 7.*
- laravel: 8.*
testbench: 6.*
- laravel: 11.*
testbench: 9.*
exclude:
- laravel: 10.*
php: 8.0
- laravel: 10.*
php: 8.1
- laravel: 11.*
php: 8.0
- laravel: 11.*
php: 8.1

name: PHP${{ matrix.php }} - Laravel ${{ matrix.laravel }}

Expand All @@ -43,9 +50,11 @@ jobs:
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --prefer-dist --no-interaction --no-suggest

- name: Run Larastan
run: vendor/bin/phpstan analyse
13 changes: 11 additions & 2 deletions .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,30 @@ on:
jobs:
run-tests:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
php: [8.0, 8.1, 8.2]
laravel: [8.*, 9.*, 10.*]
php: [8.0, 8.1, 8.2, 8.3]
laravel: ['8.*', '9.*', '10.*', '11.*']
include:
- laravel: 10.*
testbench: 8.*
- laravel: 9.*
testbench: 7.*
- laravel: 8.*
testbench: 6.*
- laravel: 11.*
testbench: 9.*
exclude:
- laravel: 10.*
php: 8.0
- laravel: 10.*
php: 8.1
- laravel: 11.*
php: 8.0
- laravel: 11.*
php: 8.1

name: PHP${{ matrix.php }} - Laravel ${{ matrix.laravel }}

Expand All @@ -43,9 +50,11 @@ jobs:
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --prefer-dist --no-interaction --no-suggest

- name: Execute tests
run: composer test
116 changes: 58 additions & 58 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,60 +1,60 @@
{
"name": "ashallendesign/laravel-config-validator",
"description": "A package for validating your Laravel app's config.",
"type": "library",
"homepage": "https://github.com/ash-jc-allen/laravel-config-validator",
"keywords": [
"ashallendesign",
"config",
"validation",
"laravel"
],
"license": "MIT",
"authors": [
{
"name": "Ash Allen",
"email": "[email protected]"
}
],
"require": {
"php": "^8.0",
"illuminate/console": "^8.0|^9.0|^10.0",
"illuminate/container": "^8.0|^9.0|^10.0",
"illuminate/validation": "^8.0|^9.0|^10.0",
"illuminate/view": "^8.0|^9.0|^10.0",
"nunomaduro/termwind": "^1.6",
"ext-json": "*"
},
"require-dev": {
"mockery/mockery": "^1.0",
"nunomaduro/larastan": "^1.0.0||^2.0.0",
"orchestra/testbench": "^6.0|^7.0|^8.0",
"phpunit/phpunit": "^9.0"
},
"autoload": {
"psr-4": {
"AshAllenDesign\\ConfigValidator\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"AshAllenDesign\\ConfigValidator\\Tests\\": "tests/"
}
},
"extra": {
"laravel": {
"providers": [
"AshAllenDesign\\ConfigValidator\\Providers\\ConfigValidatorProvider"
],
"aliases": {
"ConfigValidator": "AshAllenDesign\\ConfigValidator\\Facades\\ConfigValidator"
}
}
},
"scripts": {
"test": "vendor/bin/phpunit",
"larastan": "vendor/bin/phpstan analyse"
},
"minimum-stability": "dev",
"prefer-stable": true
"name": "ashallendesign/laravel-config-validator",
"description": "A package for validating your Laravel app's config.",
"type": "library",
"homepage": "https://github.com/ash-jc-allen/laravel-config-validator",
"keywords": [
"ashallendesign",
"config",
"validation",
"laravel"
],
"license": "MIT",
"authors": [
{
"name": "Ash Allen",
"email": "[email protected]"
}
],
"require": {
"php": "^8.0",
"illuminate/console": "^8.0|^9.0|^10.0|^11.0",
"illuminate/container": "^8.0|^9.0|^10.0|^11.0",
"illuminate/validation": "^8.0|^9.0|^10.0|^11.0",
"illuminate/view": "^8.0|^9.0|^10.0|^11.0",
"nunomaduro/termwind": "^1.6|^2.0",
"ext-json": "*"
},
"require-dev": {
"mockery/mockery": "^1.0",
"nunomaduro/larastan": "^1.0.0||^2.0.0",
"orchestra/testbench": "^6.0|^7.0|^8.0|^9.0",
"phpunit/phpunit": "^9.0|^10.5"
},
"autoload": {
"psr-4": {
"AshAllenDesign\\ConfigValidator\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"AshAllenDesign\\ConfigValidator\\Tests\\": "tests/"
}
},
"extra": {
"laravel": {
"providers": [
"AshAllenDesign\\ConfigValidator\\Providers\\ConfigValidatorProvider"
],
"aliases": {
"ConfigValidator": "AshAllenDesign\\ConfigValidator\\Facades\\ConfigValidator"
}
}
},
"scripts": {
"test": "vendor/bin/phpunit",
"larastan": "vendor/bin/phpstan analyse"
},
"minimum-stability": "dev",
"prefer-stable": true
}
70 changes: 51 additions & 19 deletions tests/Unit/Services/ConfigValidator/RunTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,15 @@ public function exception_is_thrown_if_the_validation_fails()
Config::set('cache.default', null);

$this->expectException(InvalidConfigValueException::class);
$this->expectExceptionMessage('The cache.default must be a string.');

// The validation failed message structure changed in Laravel 10.
// So we need to check for both messages depending on the
// Laravel framework version.
if (version_compare(app()->version(), '10.0.0', '>=')) {
$this->expectExceptionMessage('The cache.default field must be a string.');
} else {
$this->expectExceptionMessage('The cache.default must be a string.');
}

$stubFilePath = __DIR__.'/../../Stubs/cache.php';

Expand Down Expand Up @@ -172,24 +180,48 @@ public function validation_error_messages_can_be_returned()
// testing the error output.
}

$this->assertEquals([
'cache.default' => [
'The cache.default must be a string.',
'The cache.default field is required.',
],
'cache.prefix' => [
'The cache.prefix must be equal to foobar.',
],
'mail.from.address' => [
'The mail.from.address must be a valid email address.',
],
'mail.port' => [
'The mail.port must be an integer.',
],
'mail.field_with_underscores' => [
'The mail.field_with_underscores must be an integer.',
],
], $configValidator->errors());
// The validation failed message structure changed in Laravel 10.
// So we need to check for both messages depending on the
// Laravel framework version.
if (version_compare(app()->version(), '10.0.0', '>=')) {
$this->assertEquals([
'cache.default' => [
'The cache.default field must be a string.',
'The cache.default field is required.',
],
'cache.prefix' => [
'The cache.prefix must be equal to foobar.',
],
'mail.from.address' => [
'The mail.from.address field must be a valid email address.',
],
'mail.port' => [
'The mail.port field must be an integer.',
],
'mail.field_with_underscores' => [
'The mail.field_with_underscores field must be an integer.',
],
], $configValidator->errors());
} else {
$this->assertEquals([
'cache.default' => [
'The cache.default must be a string.',
'The cache.default field is required.',
],
'cache.prefix' => [
'The cache.prefix must be equal to foobar.',
],
'mail.from.address' => [
'The mail.from.address must be a valid email address.',
],
'mail.port' => [
'The mail.port must be an integer.',
],
'mail.field_with_underscores' => [
'The mail.field_with_underscores must be an integer.',
],
], $configValidator->errors());
}
}

/** @test */
Expand Down
Loading