Skip to content

Commit

Permalink
Update ServeCommandTest.php
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Nov 12, 2024
1 parent bb80079 commit 0cfa3ed
Showing 1 changed file with 0 additions and 46 deletions.
46 changes: 0 additions & 46 deletions packages/framework/tests/Feature/Commands/ServeCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,52 +262,6 @@ public function testHydeServeCommandWithViteOptionButViteNotRunning()
->assertExitCode(0);
}

public function testHydeServeCommandProcessLoopWithViteOptionAndViteOutput()
{
$mockViteProcess = mock(InvokedProcess::class);
$mockViteProcess->shouldReceive('running')
->times(2)
->andReturn(true, false);
$mockViteProcess->shouldReceive('latestOutput')
->once()
->andReturn('vite latest output');

$mockServerProcess = mock(InvokedProcess::class);
$mockServerProcess->shouldReceive('running')
->times(2)
->andReturn(true, false);

Process::shouldReceive('forever')
->twice()
->withNoArgs()
->andReturnSelf();

Process::shouldReceive('env')
->once()
->with(['HYDE_SERVER_REQUEST_OUTPUT' => false, 'HYDE_SERVER_VITE' => 'enabled'])
->andReturnSelf();

Process::shouldReceive('start')
->once()
->with('npm run dev')
->andReturn($mockViteProcess);

Process::shouldReceive('start')
->once()
->withArgs(function (string $command, Closure $handle) {
$handle('stdout', 'vite latest output');
return $command === "php -S localhost:8080 {$this->binaryPath()}";
})
->andReturn($mockServerProcess);

Sleep::fake();

$this->artisan('serve --no-ansi --vite')
->expectsOutput('Starting the HydeRC server... Press Ctrl+C to stop')
->expectsOutput('vite latest output')
->assertExitCode(0);
}

protected function binaryPath(): string
{
return Hyde::path('vendor/hyde/realtime-compiler/bin/server.php');
Expand Down

0 comments on commit 0cfa3ed

Please sign in to comment.