From adc5d6b14709c746a4dea4ce4ab0939f32bc9dbd Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Thu, 22 Aug 2019 16:41:46 +0200 Subject: [PATCH 1/8] Make sure 6.0 build passes --- .travis.yml | 6 ++---- composer.json | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8ffaa93b..6ac01047 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,15 +14,13 @@ env: matrix: - LARAVEL=5.7.* - LARAVEL=5.8.* - - LARAVEL=dev-master + - LARAVEL=^6.0 matrix: fast_finish: true exclude: - php: 7.1 - env: LARAVEL=dev-master - allow_failures: - - env: LARAVEL=dev-master + env: LARAVEL=^6.0 before_install: - phpenv config-rm xdebug.ini || true diff --git a/composer.json b/composer.json index 02b0ec13..894e3814 100644 --- a/composer.json +++ b/composer.json @@ -25,8 +25,8 @@ }, "require-dev": { "mockery/mockery": "^1.0", - "orchestra/testbench": "^3.7", - "phpunit/phpunit": "^7.0" + "orchestra/testbench": "^3.7|^4.0", + "phpunit/phpunit": "^7.0|^8.0" }, "autoload": { "psr-4": { From fc089b5e4650f1a1b34a3e84917086f5ee69ce3f Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Thu, 22 Aug 2019 17:06:20 +0200 Subject: [PATCH 2/8] Fix PHPUnit methods --- tests/IntegrationTest.php | 4 ++-- tests/UnitTest.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/IntegrationTest.php b/tests/IntegrationTest.php index 0e59050a..0de6fafb 100644 --- a/tests/IntegrationTest.php +++ b/tests/IntegrationTest.php @@ -32,12 +32,12 @@ protected function setUp(): void */ protected function tearDown(): void { + parent::tearDown(); + Redis::flushall(); WorkerCommandString::reset(); SupervisorCommandString::reset(); Horizon::$authUsing = null; - - parent::tearDown(); } /** diff --git a/tests/UnitTest.php b/tests/UnitTest.php index ebd5c7d7..7585cdb1 100644 --- a/tests/UnitTest.php +++ b/tests/UnitTest.php @@ -7,7 +7,7 @@ abstract class UnitTest extends TestCase { - public function tearDown() + protected function tearDown(): void { Mockery::close(); } From 5d17597d120c5da3e44860c7223b34172e5b46e4 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Thu, 22 Aug 2019 17:13:25 +0200 Subject: [PATCH 3/8] Replace deprecated PHPUnit functionality --- tests/Feature/AuthTest.php | 6 +++--- tests/Feature/MasterSupervisorTest.php | 6 +++--- tests/Feature/RedisJobRepositoryTest.php | 2 +- tests/Feature/SupervisorTest.php | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/Feature/AuthTest.php b/tests/Feature/AuthTest.php index c42e883e..5a49aac7 100644 --- a/tests/Feature/AuthTest.php +++ b/tests/Feature/AuthTest.php @@ -5,6 +5,7 @@ use Laravel\Horizon\Horizon; use Laravel\Horizon\Tests\IntegrationTest; use Laravel\Horizon\Http\Middleware\Authenticate; +use Symfony\Component\HttpKernel\Exception\HttpException; class AuthTest extends IntegrationTest { @@ -40,11 +41,10 @@ function ($value) { $this->assertSame('response', $response); } - /** - * @expectedException \Symfony\Component\HttpKernel\Exception\HttpException - */ public function test_authentication_middleware_responds_with_403_on_failure() { + $this->expectException(HttpException::class); + Horizon::auth(function () { return false; }); diff --git a/tests/Feature/MasterSupervisorTest.php b/tests/Feature/MasterSupervisorTest.php index dfcefe24..f03362d9 100644 --- a/tests/Feature/MasterSupervisorTest.php +++ b/tests/Feature/MasterSupervisorTest.php @@ -3,6 +3,7 @@ namespace Laravel\Horizon\Tests\Feature; use Mockery; +use Exception; use Laravel\Horizon\PhpBinary; use Illuminate\Support\Facades\Redis; use Laravel\Horizon\MasterSupervisor; @@ -166,11 +167,10 @@ public function test_master_process_information_is_persisted() $this->assertSame('paused', $masterRecord->status); } - /** - * @expectedException \Exception - */ public function test_master_process_should_not_allow_duplicate_master_process_on_same_machine() { + $this->expectException(Exception::class); + $master = new MasterSupervisor; $master->working = true; $master2 = new MasterSupervisor; diff --git a/tests/Feature/RedisJobRepositoryTest.php b/tests/Feature/RedisJobRepositoryTest.php index c0479d16..a3bbe93b 100644 --- a/tests/Feature/RedisJobRepositoryTest.php +++ b/tests/Feature/RedisJobRepositoryTest.php @@ -41,6 +41,6 @@ public function test_it_saves_microseconds_as_a_float_and_disregards_the_locale( $result = $repository->getRecent()[0]; - $this->assertNotContains(',', $result->reserved_at); + $this->assertStringNotContainsString(',', $result->reserved_at); } } diff --git a/tests/Feature/SupervisorTest.php b/tests/Feature/SupervisorTest.php index 94f1c6ea..e96096e7 100644 --- a/tests/Feature/SupervisorTest.php +++ b/tests/Feature/SupervisorTest.php @@ -3,6 +3,7 @@ namespace Laravel\Horizon\Tests\Feature; use Mockery; +use Exception; use Cake\Chronos\Chronos; use Laravel\Horizon\PhpBinary; use Laravel\Horizon\AutoScaler; @@ -420,11 +421,10 @@ public function test_auto_scaler_is_called_on_loop_when_auto_scaling() $supervisor->loop(); } - /** - * @expectedException \Exception - */ public function test_supervisor_with_duplicate_name_cant_be_started() { + $this->expectException(Exception::class); + $options = $this->options(); $this->supervisor = $supervisor = new Supervisor($options); $supervisor->persist(); From d3025dce91d4a52af8dd72892c1cf7436ce91d40 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Fri, 23 Aug 2019 14:22:24 +0200 Subject: [PATCH 4/8] Ignore PHPUnit cache file --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 51be8740..31aa811b 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ composer.lock Thumbs.db phpunit.xml /.idea +.phpunit.result.cache From 566f5e1ca9903563b2e03ba9364ca8c7d485d9b3 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Fri, 23 Aug 2019 14:22:36 +0200 Subject: [PATCH 5/8] Resolve dependencies correctly for worker --- tests/worker.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/tests/worker.php b/tests/worker.php index a598dc0d..87eead92 100644 --- a/tests/worker.php +++ b/tests/worker.php @@ -4,7 +4,10 @@ use Illuminate\Queue\Worker; use Illuminate\Queue\WorkerOptions; -use Orchestra\Testbench\Traits\CreatesApplication; +use \Illuminate\Queue\QueueManager; +use Illuminate\Contracts\Events\Dispatcher; +use Illuminate\Contracts\Debug\ExceptionHandler; +use Orchestra\Testbench\Concerns\CreatesApplication; $appLoader = new class { use CreatesApplication; @@ -25,10 +28,16 @@ protected function getEnvironmentSetUp($app) // Configure the application... $app = $appLoader->createApplication(); $app->register(Laravel\Horizon\HorizonServiceProvider::class); -$app['config']->set('queue.default', 'redis'); - -// Create the worker... -$worker = app(Worker::class); +$app->make('config')->set('queue.default', 'redis'); + +$worker = new Worker( + $app->make(QueueManager::class), + $app->make(Dispatcher::class), + $app->make(ExceptionHandler::class), + function () use ($app) { + return $app->isDownForMaintenance(); + } +); // Pause the worker if needed... if (in_array('--paused', $_SERVER['argv'])) { From 6f3774294ea2518b31f198cc10f9fc978c0651b1 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Fri, 23 Aug 2019 14:24:53 +0200 Subject: [PATCH 6/8] Re-arrange dependencies --- tests/worker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/worker.php b/tests/worker.php index 87eead92..e62fe85e 100644 --- a/tests/worker.php +++ b/tests/worker.php @@ -3,8 +3,8 @@ require __DIR__.'/../vendor/autoload.php'; use Illuminate\Queue\Worker; +use Illuminate\Queue\QueueManager; use Illuminate\Queue\WorkerOptions; -use \Illuminate\Queue\QueueManager; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\Debug\ExceptionHandler; use Orchestra\Testbench\Concerns\CreatesApplication; From 3b533104caa299761ce6a1c41438bdab1e2e246f Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 23 Aug 2019 09:49:53 -0500 Subject: [PATCH 7/8] fix worker command binding --- src/HorizonServiceProvider.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/HorizonServiceProvider.php b/src/HorizonServiceProvider.php index 73b2fda1..e4380fc3 100644 --- a/src/HorizonServiceProvider.php +++ b/src/HorizonServiceProvider.php @@ -105,6 +105,10 @@ public function register() define('HORIZON_PATH', realpath(__DIR__.'/../')); } + $this->app->bind(Console\WorkCommand::class, function ($app) { + return new Console\WorkCommand($app['queue.worker'], $app['cache.store']); + }); + $this->configure(); $this->offerPublishing(); $this->registerServices(); From e51da531bb421f79aeb3a77f4c31913bada79bbb Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Fri, 23 Aug 2019 17:20:23 +0200 Subject: [PATCH 8/8] Test on 7.0 --- .travis.yml | 5 +++++ composer.json | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6ac01047..22abe59e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,12 +15,17 @@ env: - LARAVEL=5.7.* - LARAVEL=5.8.* - LARAVEL=^6.0 + - LARAVEL=^7.0 matrix: fast_finish: true exclude: - php: 7.1 env: LARAVEL=^6.0 + - php: 7.1 + env: LARAVEL=^7.0 + allow_failures: + - env: LARAVEL=^7.0 before_install: - phpenv config-rm xdebug.ini || true diff --git a/composer.json b/composer.json index 894e3814..0e373fe0 100644 --- a/composer.json +++ b/composer.json @@ -15,9 +15,9 @@ "ext-pcntl": "*", "ext-posix": "*", "cakephp/chronos": "^1.0", - "illuminate/contracts": "~5.7.0|~5.8.0|^6.0", - "illuminate/queue": "~5.7.0|~5.8.0|^6.0", - "illuminate/support": "~5.7.0|~5.8.0|^6.0", + "illuminate/contracts": "~5.7.0|~5.8.0|^6.0|^7.0", + "illuminate/queue": "~5.7.0|~5.8.0|^6.0|^7.0", + "illuminate/support": "~5.7.0|~5.8.0|^6.0|^7.0", "predis/predis": "^1.1", "ramsey/uuid": "^3.5", "symfony/process": "^4.2", @@ -25,7 +25,7 @@ }, "require-dev": { "mockery/mockery": "^1.0", - "orchestra/testbench": "^3.7|^4.0", + "orchestra/testbench": "^3.7|^4.0|^5.0", "phpunit/phpunit": "^7.0|^8.0" }, "autoload": {