From b348621692f60b7815ad04e43fd545f3f7c735e2 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 15 Jan 2024 20:07:29 +0000 Subject: [PATCH] [5.x] Merge develop (#1369) * [develop] Adds L11 support (#1352) * Adds L11 support * Fixes service provider installation * Fixes service provider installation * Fixes service provider installation * Fixes static analysis * Improves test suite organization * Test without `runInSeparateProcess` * Adjusts installation process (#1353) --- .github/workflows/tests.yml | 10 +++++++- composer.json | 14 +++++------ phpunit.xml.dist | 10 ++++++-- src/Console/InstallCommand.php | 24 ++++++++++++------- .../DashboardStatsControllerTest.php | 3 ++- .../MasterSupervisorControllerTest.php | 3 ++- tests/Controller/MonitoringControllerTest.php | 3 ++- ...tControllerTest.php => ControllerTest.php} | 5 ++-- tests/Feature/SupervisorCommandTest.php | 5 ---- 9 files changed, 47 insertions(+), 30 deletions(-) rename tests/{Controller/AbstractControllerTest.php => ControllerTest.php} (66%) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0c89f78d..7f0c767a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -24,18 +24,26 @@ jobs: fail-fast: true matrix: php: [7.3, 7.4, '8.0', 8.1, 8.2, 8.3] - laravel: [8, 9, 10] + laravel: [8, 9, 10, 11] exclude: - php: 7.3 laravel: 9 - php: 7.3 laravel: 10 + - php: 7.3 + laravel: 11 - php: 7.4 laravel: 9 - php: 7.4 laravel: 10 + - php: 7.4 + laravel: 11 - php: '8.0' laravel: 10 + - php: '8.0' + laravel: 11 + - php: 8.1 + laravel: 11 - php: 8.2 laravel: 8 - php: 8.3 diff --git a/composer.json b/composer.json index 77eb0ff6..caa08811 100644 --- a/composer.json +++ b/composer.json @@ -14,19 +14,19 @@ "ext-json": "*", "ext-pcntl": "*", "ext-posix": "*", - "illuminate/contracts": "^8.17|^9.0|^10.0", - "illuminate/queue": "^8.17|^9.0|^10.0", - "illuminate/support": "^8.17|^9.0|^10.0", + "illuminate/contracts": "^8.17|^9.0|^10.0|^11.0", + "illuminate/queue": "^8.17|^9.0|^10.0|^11.0", + "illuminate/support": "^8.17|^9.0|^10.0|^11.0", "nesbot/carbon": "^2.17", "ramsey/uuid": "^4.0", - "symfony/process": "^5.0|^6.0", - "symfony/error-handler": "^5.0|^6.0" + "symfony/process": "^5.0|^6.0|^7.0", + "symfony/error-handler": "^5.0|^6.0|^7.0" }, "require-dev": { "mockery/mockery": "^1.0", - "orchestra/testbench": "^6.0|^7.0|^8.0", + "orchestra/testbench": "^6.0|^7.0|^8.0|^9.0", "phpstan/phpstan": "^1.10", - "phpunit/phpunit": "^9.0", + "phpunit/phpunit": "^9.0|^10.4", "predis/predis": "^1.1|^2.0" }, "suggest": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 9b06d672..7f532705 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -16,8 +16,14 @@ verbose="true" > - - ./tests + + ./tests/Unit + + + ./tests/Feature + + + ./tests/Controller diff --git a/src/Console/InstallCommand.php b/src/Console/InstallCommand.php index a3ee98c0..422ba1fe 100644 --- a/src/Console/InstallCommand.php +++ b/src/Console/InstallCommand.php @@ -3,6 +3,7 @@ namespace Laravel\Horizon\Console; use Illuminate\Console\Command; +use Illuminate\Support\ServiceProvider; use Illuminate\Support\Str; class InstallCommand extends Command @@ -51,17 +52,22 @@ protected function registerHorizonServiceProvider() { $namespace = Str::replaceLast('\\', '', $this->laravel->getNamespace()); - $appConfig = file_get_contents(config_path('app.php')); + if (file_exists($this->laravel->bootstrapPath('providers.php'))) { + // @phpstan-ignore-next-line + ServiceProvider::addProviderToBootstrapFile("{$namespace}\\Providers\\HorizonServiceProvider"); + } else { + $appConfig = file_get_contents(config_path('app.php')); - if (Str::contains($appConfig, $namespace.'\\Providers\\HorizonServiceProvider::class')) { - return; - } + if (Str::contains($appConfig, $namespace.'\\Providers\\HorizonServiceProvider::class')) { + return; + } - file_put_contents(config_path('app.php'), str_replace( - "{$namespace}\\Providers\EventServiceProvider::class,".PHP_EOL, - "{$namespace}\\Providers\EventServiceProvider::class,".PHP_EOL." {$namespace}\Providers\HorizonServiceProvider::class,".PHP_EOL, - $appConfig - )); + file_put_contents(config_path('app.php'), str_replace( + "{$namespace}\\Providers\EventServiceProvider::class,".PHP_EOL, + "{$namespace}\\Providers\EventServiceProvider::class,".PHP_EOL." {$namespace}\Providers\HorizonServiceProvider::class,".PHP_EOL, + $appConfig + )); + } file_put_contents(app_path('Providers/HorizonServiceProvider.php'), str_replace( "namespace App\Providers;", diff --git a/tests/Controller/DashboardStatsControllerTest.php b/tests/Controller/DashboardStatsControllerTest.php index 4bf64b15..c777b8ef 100644 --- a/tests/Controller/DashboardStatsControllerTest.php +++ b/tests/Controller/DashboardStatsControllerTest.php @@ -6,10 +6,11 @@ use Laravel\Horizon\Contracts\MasterSupervisorRepository; use Laravel\Horizon\Contracts\MetricsRepository; use Laravel\Horizon\Contracts\SupervisorRepository; +use Laravel\Horizon\Tests\ControllerTest; use Laravel\Horizon\WaitTimeCalculator; use Mockery; -class DashboardStatsControllerTest extends AbstractControllerTest +class DashboardStatsControllerTest extends ControllerTest { public function test_all_stats_are_correctly_returned() { diff --git a/tests/Controller/MasterSupervisorControllerTest.php b/tests/Controller/MasterSupervisorControllerTest.php index 668a3658..30ce38d3 100644 --- a/tests/Controller/MasterSupervisorControllerTest.php +++ b/tests/Controller/MasterSupervisorControllerTest.php @@ -7,8 +7,9 @@ use Laravel\Horizon\MasterSupervisor; use Laravel\Horizon\Supervisor; use Laravel\Horizon\SupervisorOptions; +use Laravel\Horizon\Tests\ControllerTest; -class MasterSupervisorControllerTest extends AbstractControllerTest +class MasterSupervisorControllerTest extends ControllerTest { public function test_master_supervisor_listing_without_supervisors() { diff --git a/tests/Controller/MonitoringControllerTest.php b/tests/Controller/MonitoringControllerTest.php index d5969f8e..aca9ce62 100644 --- a/tests/Controller/MonitoringControllerTest.php +++ b/tests/Controller/MonitoringControllerTest.php @@ -5,9 +5,10 @@ use Laravel\Horizon\Contracts\JobRepository; use Laravel\Horizon\Contracts\TagRepository; use Laravel\Horizon\JobPayload; +use Laravel\Horizon\Tests\ControllerTest; use Mockery; -class MonitoringControllerTest extends AbstractControllerTest +class MonitoringControllerTest extends ControllerTest { public function test_monitored_tags_and_job_counts_are_returned() { diff --git a/tests/Controller/AbstractControllerTest.php b/tests/ControllerTest.php similarity index 66% rename from tests/Controller/AbstractControllerTest.php rename to tests/ControllerTest.php index ddc2f3aa..70dc598d 100644 --- a/tests/Controller/AbstractControllerTest.php +++ b/tests/ControllerTest.php @@ -1,11 +1,10 @@ assertFalse($factory->supervisor->working); } - /** - * @runInSeparateProcess - * - * @preserveGlobalState disabled - */ public function test_supervisor_command_can_set_process_niceness() { $this->app->instance(SupervisorFactory::class, $factory = new FakeSupervisorFactory);