Skip to content

Commit

Permalink
Extract test method
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Nov 11, 2023
1 parent 603bc9b commit 21989a4
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions packages/framework/tests/Unit/ServeCommandOptionsUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,46 +16,51 @@ class ServeCommandOptionsUnitTest extends TestCase
{
public function test_getHostSelection()
{
$this->assertSame('localhost', (new ServeCommandMock())->getHostSelection());
$this->assertSame('localhost', $this->getMock()->getHostSelection());
}

public function test_getHostSelection_withHostOption()
{
$this->assertSame('foo', (new ServeCommandMock(['host' => 'foo']))->getHostSelection());
$this->assertSame('foo', $this->getMock(['host' => 'foo'])->getHostSelection());
}

public function test_getHostSelection_withConfigOption()
{
$this->app['config']->set('hyde.server.host', 'foo');
$this->assertSame('foo', (new ServeCommandMock())->getHostSelection());
$this->assertSame('foo', $this->getMock()->getHostSelection());
}

public function test_getHostSelection_withHostOptionAndConfigOption()
{
$this->app['config']->set('hyde.server.host', 'foo');
$this->assertSame('bar', (new ServeCommandMock(['host' => 'bar']))->getHostSelection());
$this->assertSame('bar', $this->getMock(['host' => 'bar'])->getHostSelection());
}

public function test_getPortSelection()
{
$this->assertSame(8080, (new ServeCommandMock())->getPortSelection());
$this->assertSame(8080, $this->getMock()->getPortSelection());
}

public function test_getPortSelection_withPortOption()
{
$this->assertSame(8081, (new ServeCommandMock(['port' => 8081]))->getPortSelection());
$this->assertSame(8081, $this->getMock(['port' => 8081])->getPortSelection());
}

public function test_getPortSelection_withConfigOption()
{
$this->app['config']->set('hyde.server.port', 8082);
$this->assertSame(8082, (new ServeCommandMock())->getPortSelection());
$this->assertSame(8082, $this->getMock()->getPortSelection());
}

public function test_getPortSelection_withPortOptionAndConfigOption()
{
$this->app['config']->set('hyde.server.port', 8082);
$this->assertSame(8081, (new ServeCommandMock(['port' => 8081]))->getPortSelection());
$this->assertSame(8081, $this->getMock(['port' => 8081])->getPortSelection());
}

protected function getMock(array $options = []): ServeCommandMock
{
return new ServeCommandMock($options);
}
}

Expand Down

0 comments on commit 21989a4

Please sign in to comment.