Skip to content

Commit

Permalink
Unit test argument logic
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Nov 28, 2023
1 parent d1b4e28 commit b79704f
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion packages/framework/tests/Unit/ServeCommandOptionsUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Mockery;
use Hyde\Testing\UnitTestCase;
use Hyde\Foundation\HydeKernel;
use Illuminate\Console\OutputStyle;
use Hyde\Console\Commands\ServeCommand;
use Illuminate\Support\Facades\Process;
Expand Down Expand Up @@ -202,6 +203,37 @@ public function test_checkArgvForOption()
}

public function testWithOpenArgument()
{
HydeKernel::setInstance(new HydeKernel());

$command = new class(['open' => true]) extends ServeCommandMock
{
public bool $openInBrowserCalled = false;

// Void unrelated methods
protected function configureOutput(): void
{
}

protected function printStartMessage(): void
{
}

protected function runServerProcess(string $command): void
{
}

protected function openInBrowser(): void
{
$this->openInBrowserCalled = true;
}
};

$command->safeHandle();
$this->assertTrue($command->openInBrowserCalled);
}

public function test_openInBrowser()
{
$output = $this->createMock(OutputStyle::class);
$output->expects($this->never())->method('writeln');
Expand All @@ -222,7 +254,7 @@ public function testWithOpenArgument()
$command->openInBrowser();
}

public function testWithOpenArgumentThatFails()
public function test_openInBrowserThatFails()
{
$output = Mockery::mock(OutputStyle::class);
$output->shouldReceive('getFormatter')->andReturn($this->createMock(OutputFormatterInterface::class));
Expand Down

0 comments on commit b79704f

Please sign in to comment.