diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 75c28a9b..872b1fed 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -4,6 +4,7 @@ on: push: branches: - master + - 'test-improvements' - '*.x' pull_request: schedule: @@ -56,8 +57,7 @@ jobs: - name: Install dependencies run: | - composer require "illuminate/contracts=^${{ matrix.laravel }}" --dev --no-update - composer update --prefer-dist --no-interaction --no-progress + composer update --prefer-dist --no-interaction --no-progress --with="illuminate/contracts:^${{ matrix.laravel }}" - name: Execute tests run: vendor/bin/phpunit diff --git a/tests/Feature/Listeners/MarkJobAsCompleteTest.php b/tests/Feature/Listeners/MarkJobAsCompleteTest.php index ab64fedd..959f3f74 100644 --- a/tests/Feature/Listeners/MarkJobAsCompleteTest.php +++ b/tests/Feature/Listeners/MarkJobAsCompleteTest.php @@ -11,25 +11,11 @@ use Laravel\Horizon\Listeners\MarkJobAsComplete; use Laravel\Horizon\Tests\IntegrationTest; use Mockery as m; +use Orchestra\Testbench\Attributes\WithConfig; +#[WithConfig('horizon.silenced', ['App\\Jobs\\ConfigJob'])] class MarkJobAsCompleteTest extends IntegrationTest { - protected function tearDown(): void - { - parent::tearDown(); - - m::close(); - } - - protected function getEnvironmentSetUp($app): void - { - parent::getEnvironmentSetUp($app); - - $app['config']->set('horizon.silenced', [ - 'App\\Jobs\\ConfigJob', - ]); - } - public function test_it_can_mark_a_job_as_complete(): void { $this->runScenario('App\\Jobs\\TestJob', false); diff --git a/tests/Feature/SupervisorTest.php b/tests/Feature/SupervisorTest.php index d1bffc5d..ee3b7e80 100644 --- a/tests/Feature/SupervisorTest.php +++ b/tests/Feature/SupervisorTest.php @@ -49,6 +49,7 @@ protected function tearDown(): void parent::tearDown(); } + /** @requires extension redis */ public function test_supervisor_can_start_worker_process_with_given_options() { Queue::push(new Jobs\BasicJob); @@ -260,6 +261,7 @@ public function test_supervisor_can_restart_processes() $this->assertNotEquals($pid, $supervisor->processes()[0]->getPid()); } + /** @requires extension redis */ public function test_processes_can_be_paused_and_continued() { $options = $this->supervisorOptions(); diff --git a/tests/IntegrationTest.php b/tests/IntegrationTest.php index 84a2b88f..d5896681 100644 --- a/tests/IntegrationTest.php +++ b/tests/IntegrationTest.php @@ -20,24 +20,18 @@ abstract class IntegrationTest extends TestCase */ protected function setUp(): void { - parent::setUp(); - - Redis::flushall(); - } + $this->afterApplicationCreated(function () { + Redis::flushall(); + }); - /** - * Tear down the test case. - * - * @return void - */ - protected function tearDown(): void - { - parent::tearDown(); + $this->beforeApplicationDestroyed(function () { + Redis::flushall(); + WorkerCommandString::reset(); + SupervisorCommandString::reset(); + Horizon::$authUsing = null; + }); - Redis::flushall(); - WorkerCommandString::reset(); - SupervisorCommandString::reset(); - Horizon::$authUsing = null; + parent::setUp(); } /** diff --git a/tests/worker.php b/tests/worker.php index f513e95d..b4e71c7e 100644 --- a/tests/worker.php +++ b/tests/worker.php @@ -7,26 +7,11 @@ use Illuminate\Queue\QueueManager; use Illuminate\Queue\Worker; use Illuminate\Queue\WorkerOptions; -use Orchestra\Testbench\Concerns\CreatesApplication; -$appLoader = new class -{ - use CreatesApplication; - - /** - * Define environment setup. - * - * @param \Illuminate\Foundation\Application $app - * @return void - */ - protected function getEnvironmentSetUp($app) - { - // Define your environment setup. - } -}; +use function Orchestra\Testbench\container; // Configure the application... -$app = $appLoader->createApplication(); +$app = container()->createApplication(); $app->register(Laravel\Horizon\HorizonServiceProvider::class); $app->make('config')->set('queue.default', 'redis');