Skip to content

Commit

Permalink
Merge branch 'master' into realtime-compiler-dashboard-improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Nov 9, 2023
2 parents ec74dda + a60c42d commit ef474e7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
1 change: 0 additions & 1 deletion packages/framework/src/Console/Commands/ServeCommand.php
Expand Up @@ -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 {
Expand Down
17 changes: 13 additions & 4 deletions packages/framework/tests/Feature/Commands/ServeCommandTest.php
Expand Up @@ -4,6 +4,7 @@

namespace Hyde\Framework\Testing\Feature\Commands;

use Closure;
use Hyde\Hyde;
use Hyde\Testing\TestCase;
use Illuminate\Support\Facades\Process;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ef474e7

Please sign in to comment.