diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2f056a2..1039858 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,8 +17,8 @@ jobs: strategy: fail-fast: false matrix: - php: ['7.4', '8.0'] - laravel: ['^8.0'] + php: ['8.0', '8.1'] + laravel: ['^9.0'] stability: [prefer-lowest, prefer-stable] name: "CI - PHP: ${{ matrix.php }} - Laravel ${{ matrix.laravel }} - ${{ matrix.stability }}" diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index da32923..ce1c110 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -19,7 +19,7 @@ jobs: php: ['8.1', '8.0'] phpstan: [^1.0] symplify-rules: ['10.1.2'] - nunomaduro-larastan: [^1.0] + nunomaduro-larastan: [^2.0] ergebnis-phpstan-rules: [^1.0] name: "PHPStan | PHP: ${{ matrix.php }}" diff --git a/CHANGELOG.md b/CHANGELOG.md index 669bcd1..61cd09d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,13 @@ All notable changes to `laravel-multienv` will be documented in this file. -## [Unreleased](https://github.com/allysonsilva/laravel-multienv/compare/v1.0.0...1.x) +## [Unreleased](https://github.com/allysonsilva/laravel-multienv/compare/v2.0.0...2.x) + +## [v2.0.0 (2022-04-13)](https://github.com/allysonsilva/laravel-multienv/compare/1.x...v2.0.0) + +### Changed + +- **Added support for Laravel v9.x** ## [v1.0.0 (2022-04-10)](https://github.com/allysonsilva/laravel-multienv/releases/tag/v1.0.0) diff --git a/README.md b/README.md index 62abcd3..a245077 100644 --- a/README.md +++ b/README.md @@ -22,8 +22,15 @@ The package has been developed and tested to work with the following minimum requirements: -- *PHP 7.4* -- *Laravel 8.0* +- *PHP 8.0* +- *Laravel 9.0* + +### Laravel version Compatibility + +| Laravel | PHP | Package | +|:-------:|:---:|:------------:| +| 9.x | 8.0 | **^2.0** | +| 8.x | 7.4 | **^1.0** | ### Install the Package @@ -289,7 +296,7 @@ If you discover any security related issues, please email github@allyson.dev ins The MIT License (MIT). Please see [License File](LICENSE.md) for more information. [ico-php]: https://img.shields.io/packagist/php-v/allysonsilva/laravel-multienv?color=%234F5B93&logo=php -[ico-laravel]: https://img.shields.io/static/v1?label=laravel&message=%E2%89%A58.0&color=ff2d20&logo=laravel +[ico-laravel]: https://img.shields.io/static/v1?label=laravel&message=%E2%89%A59.0&color=ff2d20&logo=laravel [ico-actions]: https://github.com/allysonsilva/laravel-multienv/actions/workflows/ci.yml/badge.svg [ico-codecov]: https://codecov.io/gh/allysonsilva/laravel-multienv/branch/main/graph/badge.svg?token=H546OKODQB [ico-version]: https://img.shields.io/packagist/v/allysonsilva/laravel-multienv.svg?label=stable diff --git a/composer.json b/composer.json index 310c455..fcb1102 100644 --- a/composer.json +++ b/composer.json @@ -21,11 +21,11 @@ ], "homepage": "https://github.com/allysonsilva/laravel-multienv", "require": { - "php": ">=7.4", - "laravel/framework": "^8.0" + "php": ">=8.0", + "laravel/framework": "^9.0" }, "require-dev": { - "orchestra/testbench": "^6.22", + "orchestra/testbench": "^7.0", "phpunit/phpunit": "^9.5" }, "minimum-stability": "dev", diff --git a/tests/Concerns/SetUpBefore.php b/tests/Concerns/SetUpBefore.php index ac7b724..7f8864a 100644 --- a/tests/Concerns/SetUpBefore.php +++ b/tests/Concerns/SetUpBefore.php @@ -37,16 +37,6 @@ public static function applicationBasePath() return realpath(__DIR__ . '/../LaravelApp'); } - /** - * Get base path. - * - * @return string - */ - protected function getBasePath() - { - return static::applicationBasePath(); - } - /** * Resolve application setUp. * diff --git a/tests/LaravelApp/app/Http/HttpKernel.php b/tests/LaravelApp/app/Http/HttpKernel.php index 000fa4f..6c912b5 100644 --- a/tests/LaravelApp/app/Http/HttpKernel.php +++ b/tests/LaravelApp/app/Http/HttpKernel.php @@ -18,7 +18,7 @@ class HttpKernel extends LaravelHttpKernel * @var array */ protected $middleware = [ - // \Illuminate\Http\Middleware\TrustProxies::class, + \Illuminate\Http\Middleware\TrustProxies::class, // \Illuminate\Http\Middleware\HandleCors::class, \Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance::class, \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, diff --git a/tests/LaravelApp/config/app.php b/tests/LaravelApp/config/app.php index 15f2156..02d50e9 100644 --- a/tests/LaravelApp/config/app.php +++ b/tests/LaravelApp/config/app.php @@ -1,5 +1,7 @@ [ - - 'App' => Illuminate\Support\Facades\App::class, - 'Arr' => Illuminate\Support\Arr::class, - 'Artisan' => Illuminate\Support\Facades\Artisan::class, - 'Auth' => Illuminate\Support\Facades\Auth::class, - 'Blade' => Illuminate\Support\Facades\Blade::class, - 'Broadcast' => Illuminate\Support\Facades\Broadcast::class, - 'Bus' => Illuminate\Support\Facades\Bus::class, - 'Cache' => Illuminate\Support\Facades\Cache::class, - 'Config' => Illuminate\Support\Facades\Config::class, - 'Cookie' => Illuminate\Support\Facades\Cookie::class, - 'Crypt' => Illuminate\Support\Facades\Crypt::class, - 'Date' => Illuminate\Support\Facades\Date::class, - 'DB' => Illuminate\Support\Facades\DB::class, - 'Eloquent' => Illuminate\Database\Eloquent\Model::class, - 'Event' => Illuminate\Support\Facades\Event::class, - 'File' => Illuminate\Support\Facades\File::class, - 'Gate' => Illuminate\Support\Facades\Gate::class, - 'Hash' => Illuminate\Support\Facades\Hash::class, - 'Http' => Illuminate\Support\Facades\Http::class, - 'Js' => Illuminate\Support\Js::class, - 'Lang' => Illuminate\Support\Facades\Lang::class, - 'Log' => Illuminate\Support\Facades\Log::class, - 'Mail' => Illuminate\Support\Facades\Mail::class, - 'Notification' => Illuminate\Support\Facades\Notification::class, - 'Password' => Illuminate\Support\Facades\Password::class, - 'Queue' => Illuminate\Support\Facades\Queue::class, - 'RateLimiter' => Illuminate\Support\Facades\RateLimiter::class, - 'Redirect' => Illuminate\Support\Facades\Redirect::class, - // 'Redis' => Illuminate\Support\Facades\Redis::class, - 'Request' => Illuminate\Support\Facades\Request::class, - 'Response' => Illuminate\Support\Facades\Response::class, - 'Route' => Illuminate\Support\Facades\Route::class, - 'Schema' => Illuminate\Support\Facades\Schema::class, - 'Session' => Illuminate\Support\Facades\Session::class, - 'Storage' => Illuminate\Support\Facades\Storage::class, - 'Str' => Illuminate\Support\Str::class, - 'URL' => Illuminate\Support\Facades\URL::class, - 'Validator' => Illuminate\Support\Facades\Validator::class, - 'View' => Illuminate\Support\Facades\View::class, - - ], + 'aliases' => Facade::defaultAliases()->merge([ + // ... + ])->toArray(), ]; diff --git a/tests/LaravelApp/config/broadcasting.php b/tests/LaravelApp/config/broadcasting.php index 2d52982..67fcbbd 100644 --- a/tests/LaravelApp/config/broadcasting.php +++ b/tests/LaravelApp/config/broadcasting.php @@ -39,6 +39,9 @@ 'cluster' => env('PUSHER_APP_CLUSTER'), 'useTLS' => true, ], + 'client_options' => [ + // Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html + ], ], 'ably' => [ diff --git a/tests/LaravelApp/config/cache.php b/tests/LaravelApp/config/cache.php index 8736c7a..0ad5c74 100644 --- a/tests/LaravelApp/config/cache.php +++ b/tests/LaravelApp/config/cache.php @@ -105,6 +105,6 @@ | */ - 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'), + 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache_'), ]; diff --git a/tests/LaravelApp/config/database.php b/tests/LaravelApp/config/database.php index f7bf056..0fe3bdf 100644 --- a/tests/LaravelApp/config/database.php +++ b/tests/LaravelApp/config/database.php @@ -81,7 +81,7 @@ 'charset' => 'utf8', 'prefix' => '', 'prefix_indexes' => true, - 'schema' => 'public', + 'search_path' => 'public', 'sslmode' => 'prefer', ], @@ -136,7 +136,7 @@ 'default' => [ 'url' => env('REDIS_URL'), 'host' => env('REDIS_HOST', '127.0.0.1'), - 'password' => env('REDIS_PASSWORD', null), + 'password' => env('REDIS_PASSWORD'), 'port' => env('REDIS_PORT', '6379'), 'database' => env('REDIS_DB', '0'), ], @@ -144,7 +144,7 @@ 'cache' => [ 'url' => env('REDIS_URL'), 'host' => env('REDIS_HOST', '127.0.0.1'), - 'password' => env('REDIS_PASSWORD', null), + 'password' => env('REDIS_PASSWORD'), 'port' => env('REDIS_PORT', '6379'), 'database' => env('REDIS_CACHE_DB', '1'), ], diff --git a/tests/LaravelApp/config/filesystems.php b/tests/LaravelApp/config/filesystems.php index 760ef97..cf5abce 100644 --- a/tests/LaravelApp/config/filesystems.php +++ b/tests/LaravelApp/config/filesystems.php @@ -13,7 +13,7 @@ | */ - 'default' => env('FILESYSTEM_DRIVER', 'local'), + 'default' => env('FILESYSTEM_DISK', 'local'), /* |-------------------------------------------------------------------------- diff --git a/tests/LaravelApp/config/logging.php b/tests/LaravelApp/config/logging.php index 880cd92..fefe088 100644 --- a/tests/LaravelApp/config/logging.php +++ b/tests/LaravelApp/config/logging.php @@ -78,10 +78,11 @@ 'papertrail' => [ 'driver' => 'monolog', 'level' => env('LOG_LEVEL', 'debug'), - 'handler' => SyslogUdpHandler::class, + 'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class), 'handler_with' => [ 'host' => env('PAPERTRAIL_URL'), 'port' => env('PAPERTRAIL_PORT'), + 'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'), ], ], diff --git a/tests/LaravelApp/config/mail.php b/tests/LaravelApp/config/mail.php index f96c6c7..87b6fe3 100644 --- a/tests/LaravelApp/config/mail.php +++ b/tests/LaravelApp/config/mail.php @@ -42,7 +42,6 @@ 'username' => env('MAIL_USERNAME'), 'password' => env('MAIL_PASSWORD'), 'timeout' => null, - 'auth_mode' => null, ], 'ses' => [ diff --git a/tests/LaravelApp/config/session.php b/tests/LaravelApp/config/session.php index ac0802b..8fed97c 100644 --- a/tests/LaravelApp/config/session.php +++ b/tests/LaravelApp/config/session.php @@ -72,7 +72,7 @@ | */ - 'connection' => env('SESSION_CONNECTION', null), + 'connection' => env('SESSION_CONNECTION'), /* |-------------------------------------------------------------------------- @@ -100,7 +100,7 @@ | */ - 'store' => env('SESSION_STORE', null), + 'store' => env('SESSION_STORE'), /* |-------------------------------------------------------------------------- @@ -155,7 +155,7 @@ | */ - 'domain' => env('SESSION_DOMAIN', null), + 'domain' => env('SESSION_DOMAIN'), /* |-------------------------------------------------------------------------- diff --git a/tests/Orchestra/Commander.php b/tests/Orchestra/Commander.php index c48ea02..6a58a22 100644 --- a/tests/Orchestra/Commander.php +++ b/tests/Orchestra/Commander.php @@ -24,7 +24,7 @@ public static function applicationBasePath() public function laravel() { if (! $this->app) { - $this->app = Application::create($this->getBasePath(), null, [ + $this->app = Application::create(basePath: $this->getBasePath(), options: [ 'extra' => [ 'providers' => $this->config['providers'] ?? [], 'dont-discover' => $this->config['dont-discover'] ?? [], diff --git a/tests/TestCase.php b/tests/TestCase.php index ae64fb4..d87bb98 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -33,7 +33,9 @@ protected function setUp(): void if (! is_file("{$this->getBasePath()}/config/envs.php")) { $this->copyEnvsToRoot('.env.non-existent-domain'); - $this->artisan('vendor:publish', ['--tag' => 'envs-config', '--force' => true, ])->run(); + $this->artisan('vendor:publish', ['--tag' => 'envs-config', '--force' => true, ]) + ->assertSuccessful() + ->run(); $this->app->make(LaravelLoadConfiguration::class)->bootstrap($this->app); } diff --git a/tests/Unit/ArtisanTest.php b/tests/Unit/ArtisanTest.php index 4b85eaa..2df8154 100644 --- a/tests/Unit/ArtisanTest.php +++ b/tests/Unit/ArtisanTest.php @@ -26,6 +26,7 @@ public function using_APP_ROUTES_CACHE_key_to_cache_domain_routes(): void $this->updateEnvsConfigFile(); $this->artisan('route:cache', ['--domain' => 'site1.test']) + ->assertSuccessful() ->expectsOutput(Mockery::pattern('/^Route cache cleared/')) ->expectsOutput(Mockery::pattern('/^Routes cached successfully/')); @@ -40,9 +41,11 @@ public function using_APP_ROUTES_CACHE_key_to_cache_domain_routes(): void self::assertSame($this->app->getCachedRoutesPath(), $cachedRoutesFilename); $this->get('http://site1.test') + ->assertSuccessful() ->assertSeeText('site1.test/'); $this->get('http://site1.test/other') + ->assertSuccessful() ->assertSeeText('site1.test/other'); $this->get('http://site2.test') @@ -71,6 +74,7 @@ public function using_APP_ROUTES_CACHE_key_to_cache_domain_routes(): void public function cache_all_routes_when_domain_does_not_exist(): void { $this->artisan('route:cache') + ->assertSuccessful() ->expectsOutput(Mockery::pattern('/^Route cache cleared/')) ->expectsOutput(Mockery::pattern('/^Routes cached successfully/')); @@ -87,12 +91,15 @@ public function cache_all_routes_when_domain_does_not_exist(): void self::assertSame($this->app->getCachedRoutesPath(), $cachedRoutesFilename); $this->get('http://site1.test') + ->assertSuccessful() ->assertSeeText('site1.test/'); $this->get('http://site2.test/') + ->assertSuccessful() ->assertSeeText('site2.test/'); $this->get('http://other-domain.test/') + ->assertSuccessful() ->assertSeeText('other-domain.test/'); } @@ -119,6 +126,7 @@ public function using_APP_CONFIG_CACHE_key_to_cache_domain_configs(): void // $consoleOutput = $this->runArtisan('config:cache', '--domain=site-XYZ.test')->getOutput(); $this->artisan('config:cache', ['--domain' => 'site2.test']) + ->assertSuccessful() ->expectsOutput(Mockery::pattern('/^Configuration cache cleared/')) ->expectsOutput(Mockery::pattern('/^Configuration cached successfully/')) ->run(); @@ -138,6 +146,7 @@ public function using_APP_CONFIG_CACHE_key_to_cache_domain_configs(): void Env::getRepository()->clear('APP_CONFIG_CACHE'); $this->artisan('config:cache', ['--domain' => 'site1.test']) + ->assertSuccessful() ->expectsOutput(Mockery::pattern('/^Configuration cache cleared/')) ->expectsOutput(Mockery::pattern('/^Configuration cached successfully/')) ->run(); @@ -162,6 +171,7 @@ public function using_APP_CONFIG_CACHE_key_to_cache_domain_configs(): void public function cache_all_configs_when_domain_does_not_exist(): void { $this->artisan('config:cache') + ->assertSuccessful() ->expectsOutput(Mockery::pattern('/^Configuration cache cleared/')) ->expectsOutput(Mockery::pattern('/^Configuration cached successfully/')); diff --git a/tests/Unit/HttpTest.php b/tests/Unit/HttpTest.php index 6f4f069..4a5707a 100644 --- a/tests/Unit/HttpTest.php +++ b/tests/Unit/HttpTest.php @@ -16,11 +16,9 @@ protected function setUp(): void { parent::setUp(); - Route::domain('site2.test')->group(function () { - Route::get('domain-route', function () { - return response()->json(config('domain')); - })->middleware(['api']); - }); + Route::domain('site2.test') + ->get('domain-route', fn () => response()->json(config('domain'))) + ->middleware(['api']); } /** @@ -43,6 +41,7 @@ public function custom_domain_env_filename(): void // $this->refreshConfiguration(); $this->getJson('http://site2.test/domain-route') + ->assertSuccessful() ->assertJson($this->getFixture('env.site2')['domain']); } }