Skip to content

Commit

Permalink
fix publicUrl nullability
Browse files Browse the repository at this point in the history
  • Loading branch information
jiripudil committed Jan 7, 2020
1 parent 9c7e777 commit f292925
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/DI/WebpackExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function loadConfiguration(): void
->setFactory(DevServer::class, [
$config['devServer']['enabled'],
$config['devServer']['url'] ?? '',
$config['devServer']['publicUrl'] ?? '',
$config['devServer']['publicUrl'],
$config['devServer']['timeout'],
new Statement(Client::class),
]);
Expand Down
4 changes: 2 additions & 2 deletions src/DevServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class DevServer
private $url;

/**
* @var string
* @var ?string
*/
private $publicUrl;

Expand All @@ -42,7 +42,7 @@ class DevServer
private $httpClient;


public function __construct(bool $enabled, string $url, string $publicUrl, float $timeout, ClientInterface $httpClient)
public function __construct(bool $enabled, string $url, ?string $publicUrl, float $timeout, ClientInterface $httpClient)
{
$this->enabled = $enabled;
$this->url = $url;
Expand Down
7 changes: 4 additions & 3 deletions tests/WebpackNetteAdapter/DevServerTest.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ class DevServerTest extends TestCase

public function testDevServer(): void
{
$devServer = new DevServer(TRUE, 'http://localhost:3000', '', 0.1, $this->httpClient);
$devServer = new DevServer(TRUE, 'http://localhost:3000', NULL, 0.1, $this->httpClient);
Assert::true($devServer->isEnabled());
Assert::same($devServer->getUrl(), 'http://localhost:3000');

$this->httpClient->shouldReceive('request')
->with('GET', 'http://localhost:3000', ['http_errors' => FALSE, 'verify' => FALSE, 'timeout' => 0.1])
Expand All @@ -64,7 +65,7 @@ class DevServerTest extends TestCase

public function testUnavailable(): void
{
$devServer = new DevServer(TRUE, 'http://localhost:3000', '', 0.5, $this->httpClient);
$devServer = new DevServer(TRUE, 'http://localhost:3000', NULL, 0.5, $this->httpClient);
Assert::true($devServer->isEnabled());

$this->httpClient->shouldReceive('request')
Expand All @@ -76,7 +77,7 @@ class DevServerTest extends TestCase

public function testDisabled(): void
{
$devServer = new DevServer(FALSE, 'http://localhost:3000', '', 0.1, $this->httpClient);
$devServer = new DevServer(FALSE, 'http://localhost:3000', NULL, 0.1, $this->httpClient);
Assert::false($devServer->isEnabled());
Assert::false($devServer->isAvailable());
}
Expand Down

0 comments on commit f292925

Please sign in to comment.