diff --git a/packages/framework/src/Console/Commands/ServeCommand.php b/packages/framework/src/Console/Commands/ServeCommand.php index fe5ce803c1f..78170117487 100644 --- a/packages/framework/src/Console/Commands/ServeCommand.php +++ b/packages/framework/src/Console/Commands/ServeCommand.php @@ -52,7 +52,6 @@ protected function getExecutablePath(): string return Hyde::path('vendor/hyde/realtime-compiler/bin/server.php'); } - /** @codeCoverageIgnore Until output is testable */ protected function runServerProcess(string $command): void { Process::forever()->run($command, function (string $type, string $line): void { diff --git a/packages/framework/tests/Feature/Commands/ServeCommandTest.php b/packages/framework/tests/Feature/Commands/ServeCommandTest.php index db0f4ec0fd1..1dec744c9ed 100644 --- a/packages/framework/tests/Feature/Commands/ServeCommandTest.php +++ b/packages/framework/tests/Feature/Commands/ServeCommandTest.php @@ -4,6 +4,7 @@ namespace Hyde\Framework\Testing\Feature\Commands; +use Closure; use Hyde\Hyde; use Hyde\Testing\TestCase; use Illuminate\Support\Facades\Process; @@ -135,16 +136,24 @@ public function test_hyde_serve_command_with_invalid_config_value() public function test_hyde_serve_command_passes_through_process_output() { - $this->markTestSkipped('Unable to access the output of the process. Assuming vendor bug for now.'); + Process::shouldReceive('forever') + ->once() + ->withNoArgs() + ->andReturnSelf(); - Process::fake(['php -S localhost:8080 {$this->binaryPath()}' => 'foo']); + Process::shouldReceive('run') + ->once() + ->withArgs(function (string $command, Closure $handle) { + $handle('type', 'foo'); + + return $command === "php -S localhost:8080 {$this->binaryPath()}"; + }) + ->andReturnSelf(); $this->artisan('serve') ->expectsOutput('Starting the HydeRC server... Press Ctrl+C to stop') ->expectsOutput('foo') ->assertExitCode(0); - - Process::assertRan("php -S localhost:8080 {$this->binaryPath()}"); } protected function binaryPath(): string