Skip to content

Commit

Permalink
Test Improvements (#1511)
Browse files Browse the repository at this point in the history
* wip

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* wip

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* wip

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* wip

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* wip

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* wip

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* wip

Signed-off-by: Mior Muhammad Zaki <[email protected]>

---------

Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone authored Oct 29, 2024
1 parent ff182b3 commit 97eccbd
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 51 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- master
- 'test-improvements'
- '*.x'
pull_request:
schedule:
Expand Down Expand Up @@ -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
18 changes: 2 additions & 16 deletions tests/Feature/Listeners/MarkJobAsCompleteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions tests/Feature/SupervisorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down
26 changes: 10 additions & 16 deletions tests/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down
19 changes: 2 additions & 17 deletions tests/worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down

0 comments on commit 97eccbd

Please sign in to comment.