Skip to content

Commit

Permalink
[2.x] Fix inter test dependencies (#914)
Browse files Browse the repository at this point in the history
* Flush container between tests

* Ensure app is available when needed
  • Loading branch information
timacdonald authored Jun 19, 2024
1 parent 710e72d commit 4145a69
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/RoadRunnerServerProcessInspectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public function test_can_determine_if_roadrunner_server_process_is_running_when_
/** @doesNotPerformAssertions @test */
public function test_roadrunner_server_process_can_be_reloaded()
{
$this->createApplication();
$inspector = new ServerProcessInspector(
$processIdFile = new ServerStateFile(sys_get_temp_dir().'/swoole.pid'),
$processFactory = Mockery::mock(SymfonyProcessFactory::class),
Expand Down
3 changes: 3 additions & 0 deletions tests/SequentialTaskDispatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public function test_tasks_can_be_resolved()

public function test_resolving_tasks_with_exceptions_do_not_effect_other_tasks()
{
$this->createApplication();
$dispatcher = new SequentialTaskDispatcher;

$a = false;
Expand Down Expand Up @@ -77,6 +78,7 @@ public function test_tasks_can_be_dispatched()

public function test_resolving_tasks_propagate_exceptions()
{
$this->createApplication();
$dispatcher = new SequentialTaskDispatcher();

$this->expectException(TaskException::class);
Expand All @@ -89,6 +91,7 @@ public function test_resolving_tasks_propagate_exceptions()

public function test_resolving_tasks_propagate_dd_calls()
{
$this->createApplication();
$dispatcher = new SequentialTaskDispatcher();

$this->expectException(DdException::class);
Expand Down
5 changes: 5 additions & 0 deletions tests/SwooleClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ public function test_static_file_can_be_served(): void
/** @doesNotPerformAssertions @test */
public function test_static_file_headers_can_be_sent(): void
{
$this->createApplication();
$client = new SwooleClient;

$request = Request::create('/foo.txt', 'GET');
Expand Down Expand Up @@ -206,6 +207,7 @@ public function test_respond_method_sends_response_to_swoole(): void
/** @doesNotPerformAssertions @test */
public function test_respond_method_send_streamed_response_to_swoole(): void
{
$this->createApplication();
$client = new SwooleClient;

$swooleResponse = Mockery::mock('Swoole\Http\Response');
Expand All @@ -227,6 +229,7 @@ public function test_respond_method_send_streamed_response_to_swoole(): void
/** @doesNotPerformAssertions @test */
public function test_respond_method_with_laravel_specific_status_code_sends_response_to_swoole(): void
{
$this->createApplication();
$client = new SwooleClient;

$swooleResponse = Mockery::mock('Swoole\Http\Response');
Expand Down Expand Up @@ -286,6 +289,7 @@ public function test_error_method_sends_detailed_error_response_to_swoole_in_deb
/** @doesNotPerformAssertions @test */
public function test_respond_method_send_not_chunked_response_to_swoole(): void
{
$this->createApplication();
$client = new SwooleClient;

$swooleResponse = Mockery::mock(SwooleResponse::class);
Expand All @@ -307,6 +311,7 @@ public function test_respond_method_send_not_chunked_response_to_swoole(): void
/** @doesNotPerformAssertions @test */
public function test_respond_method_send_chunked_response_to_swoole(): void
{
$this->createApplication();
$client = new SwooleClient(6);

$swooleResponse = Mockery::mock('Swoole\Http\Response');
Expand Down
7 changes: 7 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace Laravel\Octane\Tests;

use Carbon\Laravel\ServiceProvider as CarbonServiceProvider;
use Illuminate\Container\Container;
use Illuminate\Support\Facades\Facade;
use Laravel\Octane\ApplicationFactory;
use Laravel\Octane\Contracts\Client;
use Laravel\Octane\Octane;
Expand Down Expand Up @@ -72,6 +74,11 @@ protected function tearDown(): void
{
parent::tearDown();

Container::setInstance(null);

Facade::clearResolvedInstances();
Facade::setFacadeApplication(null);

Mockery::close();
}
}

0 comments on commit 4145a69

Please sign in to comment.